Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Pierre Ossman | aaac1b4 | 2007-02-28 15:33:10 +0100 | [diff] [blame] | 2 | * linux/drivers/mmc/core/core.h |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2003 Russell King, All Rights Reserved. |
Pierre Ossman | da7fbe5 | 2006-12-24 22:46:55 +0100 | [diff] [blame] | 5 | * Copyright 2007 Pierre Ossman |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * |
| 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 Ossman | da7fbe5 | 2006-12-24 22:46:55 +0100 | [diff] [blame] | 11 | #ifndef _MMC_CORE_CORE_H |
| 12 | #define _MMC_CORE_CORE_H |
Russell King | 00b137c | 2005-08-19 09:41:24 +0100 | [diff] [blame] | 13 | |
Pierre Ossman | da7fbe5 | 2006-12-24 22:46:55 +0100 | [diff] [blame] | 14 | #include <linux/delay.h> |
Pierre Ossman | 7104e2d | 2006-10-04 02:15:41 -0700 | [diff] [blame] | 15 | |
Pierre Ossman | da7fbe5 | 2006-12-24 22:46:55 +0100 | [diff] [blame] | 16 | #define MMC_CMD_RETRIES 3 |
| 17 | |
Pierre Ossman | 7ea239d | 2006-12-31 00:11:32 +0100 | [diff] [blame] | 18 | struct mmc_bus_ops { |
Jarkko Lavinen | b1ebe38 | 2009-09-22 16:44:34 -0700 | [diff] [blame] | 19 | int (*awake)(struct mmc_host *); |
| 20 | int (*sleep)(struct mmc_host *); |
Pierre Ossman | 7ea239d | 2006-12-31 00:11:32 +0100 | [diff] [blame] | 21 | void (*remove)(struct mmc_host *); |
| 22 | void (*detect)(struct mmc_host *); |
Nicolas Pitre | 95cdfb7 | 2009-09-22 16:45:29 -0700 | [diff] [blame] | 23 | int (*suspend)(struct mmc_host *); |
| 24 | int (*resume)(struct mmc_host *); |
Ohad Ben-Cohen | 12ae637 | 2010-10-02 13:54:06 +0200 | [diff] [blame] | 25 | int (*power_save)(struct mmc_host *); |
| 26 | int (*power_restore)(struct mmc_host *); |
Pierre Ossman | 7ea239d | 2006-12-31 00:11:32 +0100 | [diff] [blame] | 27 | }; |
| 28 | |
| 29 | void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops); |
| 30 | void mmc_detach_bus(struct mmc_host *host); |
| 31 | |
Adrian Hunter | dfe86cb | 2010-08-11 14:17:46 -0700 | [diff] [blame] | 32 | void mmc_init_erase(struct mmc_card *card); |
| 33 | |
Pierre Ossman | da7fbe5 | 2006-12-24 22:46:55 +0100 | [diff] [blame] | 34 | void mmc_set_chip_select(struct mmc_host *host, int mode); |
Pierre Ossman | 7ea239d | 2006-12-31 00:11:32 +0100 | [diff] [blame] | 35 | void mmc_set_clock(struct mmc_host *host, unsigned int hz); |
Linus Walleij | 0456683 | 2010-11-08 21:36:50 -0500 | [diff] [blame] | 36 | void mmc_gate_clock(struct mmc_host *host); |
| 37 | void mmc_ungate_clock(struct mmc_host *host); |
| 38 | void mmc_set_ungated(struct mmc_host *host); |
Pierre Ossman | 7ea239d | 2006-12-31 00:11:32 +0100 | [diff] [blame] | 39 | void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode); |
| 40 | void mmc_set_bus_width(struct mmc_host *host, unsigned int width); |
| 41 | u32 mmc_select_voltage(struct mmc_host *host, u32 ocr); |
Philip Rakity | 261bbd4 | 2011-05-13 11:17:17 +0530 | [diff] [blame] | 42 | int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, |
| 43 | bool cmd11); |
Pierre Ossman | 7ea239d | 2006-12-31 00:11:32 +0100 | [diff] [blame] | 44 | void mmc_set_timing(struct mmc_host *host, unsigned int timing); |
Arindam Nath | d6d50a1 | 2011-05-05 12:18:59 +0530 | [diff] [blame] | 45 | void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type); |
Ulf Hansson | 7f7e412 | 2011-09-21 14:08:13 -0400 | [diff] [blame] | 46 | void mmc_power_off(struct mmc_host *host); |
Pierre Ossman | 7ea239d | 2006-12-31 00:11:32 +0100 | [diff] [blame] | 47 | |
Pierre Ossman | da7fbe5 | 2006-12-24 22:46:55 +0100 | [diff] [blame] | 48 | static 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 Ossman | b93931a | 2007-05-19 14:06:24 +0200 | [diff] [blame] | 58 | void mmc_rescan(struct work_struct *work); |
| 59 | void mmc_start_host(struct mmc_host *host); |
| 60 | void mmc_stop_host(struct mmc_host *host); |
| 61 | |
Andy Ross | 807e8e4 | 2011-01-03 10:36:56 -0800 | [diff] [blame] | 62 | int mmc_attach_mmc(struct mmc_host *host); |
| 63 | int mmc_attach_sd(struct mmc_host *host); |
| 64 | int mmc_attach_sdio(struct mmc_host *host); |
Adrian Bunk | 98b843b | 2008-04-13 21:15:50 +0300 | [diff] [blame] | 65 | |
Ben Hutchings | bd68e08 | 2009-12-14 18:01:29 -0800 | [diff] [blame] | 66 | /* Module parameters */ |
David Brownell | af51715 | 2007-08-08 09:11:32 -0700 | [diff] [blame] | 67 | extern int use_spi_crc; |
| 68 | |
Haavard Skinnemoen | 6edd8ee | 2008-07-24 14:18:57 +0200 | [diff] [blame] | 69 | /* Debugfs information for hosts and cards */ |
| 70 | void mmc_add_host_debugfs(struct mmc_host *host); |
| 71 | void mmc_remove_host_debugfs(struct mmc_host *host); |
| 72 | |
Haavard Skinnemoen | f4b7f92 | 2008-07-24 14:18:58 +0200 | [diff] [blame] | 73 | void mmc_add_card_debugfs(struct mmc_card *card); |
| 74 | void mmc_remove_card_debugfs(struct mmc_card *card); |
| 75 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | #endif |
Pierre Ossman | da7fbe5 | 2006-12-24 22:46:55 +0100 | [diff] [blame] | 77 | |