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 { |
| 19 | void (*remove)(struct mmc_host *); |
| 20 | void (*detect)(struct mmc_host *); |
Ulf Hansson | 810cadd | 2013-06-10 17:03:37 +0200 | [diff] [blame] | 21 | int (*pre_suspend)(struct mmc_host *); |
Nicolas Pitre | 95cdfb7 | 2009-09-22 16:45:29 -0700 | [diff] [blame] | 22 | int (*suspend)(struct mmc_host *); |
| 23 | int (*resume)(struct mmc_host *); |
Ulf Hansson | 12d01d0 | 2013-05-02 14:02:37 +0200 | [diff] [blame] | 24 | int (*runtime_suspend)(struct mmc_host *); |
| 25 | int (*runtime_resume)(struct mmc_host *); |
Ohad Ben-Cohen | 12ae637 | 2010-10-02 13:54:06 +0200 | [diff] [blame] | 26 | int (*power_save)(struct mmc_host *); |
| 27 | int (*power_restore)(struct mmc_host *); |
Adrian Hunter | d304950 | 2011-11-28 16:22:00 +0200 | [diff] [blame] | 28 | int (*alive)(struct mmc_host *); |
Ulf Hansson | 6b086bd | 2013-06-10 17:03:41 +0200 | [diff] [blame] | 29 | int (*shutdown)(struct mmc_host *); |
Johan Rudholm | f855a37 | 2015-01-12 15:38:05 +0100 | [diff] [blame] | 30 | int (*reset)(struct mmc_host *); |
Pierre Ossman | 7ea239d | 2006-12-31 00:11:32 +0100 | [diff] [blame] | 31 | }; |
| 32 | |
| 33 | void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops); |
| 34 | void mmc_detach_bus(struct mmc_host *host); |
| 35 | |
Sascha Hauer | 25185f3 | 2014-06-30 11:07:25 +0200 | [diff] [blame] | 36 | struct device_node *mmc_of_find_child_device(struct mmc_host *host, |
| 37 | unsigned func_num); |
| 38 | |
Adrian Hunter | dfe86cb | 2010-08-11 14:17:46 -0700 | [diff] [blame] | 39 | void mmc_init_erase(struct mmc_card *card); |
| 40 | |
Pierre Ossman | da7fbe5 | 2006-12-24 22:46:55 +0100 | [diff] [blame] | 41 | void mmc_set_chip_select(struct mmc_host *host, int mode); |
Pierre Ossman | 7ea239d | 2006-12-31 00:11:32 +0100 | [diff] [blame] | 42 | void mmc_set_clock(struct mmc_host *host, unsigned int hz); |
| 43 | void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode); |
| 44 | void mmc_set_bus_width(struct mmc_host *host, unsigned int width); |
| 45 | u32 mmc_select_voltage(struct mmc_host *host, u32 ocr); |
Ulf Hansson | 0f791fd | 2013-09-12 15:36:34 +0200 | [diff] [blame] | 46 | int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, u32 ocr); |
Johan Rudholm | 567c890 | 2013-01-28 15:08:27 +0100 | [diff] [blame] | 47 | int __mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage); |
Pierre Ossman | 7ea239d | 2006-12-31 00:11:32 +0100 | [diff] [blame] | 48 | void mmc_set_timing(struct mmc_host *host, unsigned int timing); |
Arindam Nath | d6d50a1 | 2011-05-05 12:18:59 +0530 | [diff] [blame] | 49 | void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type); |
Adrian Hunter | e23350b | 2015-02-06 14:12:55 +0200 | [diff] [blame] | 50 | int mmc_select_drive_strength(struct mmc_card *card, unsigned int max_dtr, |
| 51 | int card_drv_type, int *drv_type); |
Ulf Hansson | 4a06519 | 2013-09-12 14:36:53 +0200 | [diff] [blame] | 52 | void mmc_power_up(struct mmc_host *host, u32 ocr); |
Ulf Hansson | 7f7e412 | 2011-09-21 14:08:13 -0400 | [diff] [blame] | 53 | void mmc_power_off(struct mmc_host *host); |
Ulf Hansson | 4a06519 | 2013-09-12 14:36:53 +0200 | [diff] [blame] | 54 | void mmc_power_cycle(struct mmc_host *host, u32 ocr); |
Johan Rudholm | 2d079c4 | 2014-11-06 14:46:54 +0100 | [diff] [blame] | 55 | void mmc_set_initial_state(struct mmc_host *host); |
Pierre Ossman | 7ea239d | 2006-12-31 00:11:32 +0100 | [diff] [blame] | 56 | |
Pierre Ossman | da7fbe5 | 2006-12-24 22:46:55 +0100 | [diff] [blame] | 57 | static inline void mmc_delay(unsigned int ms) |
| 58 | { |
| 59 | if (ms < 1000 / HZ) { |
| 60 | cond_resched(); |
| 61 | mdelay(ms); |
| 62 | } else { |
| 63 | msleep(ms); |
| 64 | } |
| 65 | } |
| 66 | |
Pierre Ossman | b93931a | 2007-05-19 14:06:24 +0200 | [diff] [blame] | 67 | void mmc_rescan(struct work_struct *work); |
| 68 | void mmc_start_host(struct mmc_host *host); |
| 69 | void mmc_stop_host(struct mmc_host *host); |
| 70 | |
Adrian Hunter | d304950 | 2011-11-28 16:22:00 +0200 | [diff] [blame] | 71 | int _mmc_detect_card_removed(struct mmc_host *host); |
| 72 | |
Andy Ross | 807e8e4 | 2011-01-03 10:36:56 -0800 | [diff] [blame] | 73 | int mmc_attach_mmc(struct mmc_host *host); |
| 74 | int mmc_attach_sd(struct mmc_host *host); |
| 75 | int mmc_attach_sdio(struct mmc_host *host); |
Adrian Bunk | 98b843b | 2008-04-13 21:15:50 +0300 | [diff] [blame] | 76 | |
Ben Hutchings | bd68e08 | 2009-12-14 18:01:29 -0800 | [diff] [blame] | 77 | /* Module parameters */ |
Rusty Russell | 90ab5ee | 2012-01-13 09:32:20 +1030 | [diff] [blame] | 78 | extern bool use_spi_crc; |
David Brownell | af51715 | 2007-08-08 09:11:32 -0700 | [diff] [blame] | 79 | |
Haavard Skinnemoen | 6edd8ee | 2008-07-24 14:18:57 +0200 | [diff] [blame] | 80 | /* Debugfs information for hosts and cards */ |
| 81 | void mmc_add_host_debugfs(struct mmc_host *host); |
| 82 | void mmc_remove_host_debugfs(struct mmc_host *host); |
| 83 | |
Haavard Skinnemoen | f4b7f92 | 2008-07-24 14:18:58 +0200 | [diff] [blame] | 84 | void mmc_add_card_debugfs(struct mmc_card *card); |
| 85 | void mmc_remove_card_debugfs(struct mmc_card *card); |
| 86 | |
Konstantin Dorfman | 2220eed | 2013-01-14 14:28:17 -0500 | [diff] [blame] | 87 | void mmc_init_context_info(struct mmc_host *host); |
Adrian Hunter | 63e415c | 2014-12-05 19:40:59 +0200 | [diff] [blame] | 88 | |
| 89 | int mmc_execute_tuning(struct mmc_card *card); |
Adrian Hunter | 6376f69 | 2015-05-07 13:10:20 +0300 | [diff] [blame] | 90 | int mmc_hs200_to_hs400(struct mmc_card *card); |
| 91 | int mmc_hs400_to_hs200(struct mmc_card *card); |
Adrian Hunter | 63e415c | 2014-12-05 19:40:59 +0200 | [diff] [blame] | 92 | |
Ulf Hansson | 8dede18 | 2015-11-05 16:11:12 +0100 | [diff] [blame] | 93 | #ifdef CONFIG_PM_SLEEP |
| 94 | void mmc_register_pm_notifier(struct mmc_host *host); |
| 95 | void mmc_unregister_pm_notifier(struct mmc_host *host); |
| 96 | #else |
Arnd Bergmann | fb0229d | 2015-11-20 11:28:42 +0100 | [diff] [blame] | 97 | static inline void mmc_register_pm_notifier(struct mmc_host *host) { } |
| 98 | static inline void mmc_unregister_pm_notifier(struct mmc_host *host) { } |
Ulf Hansson | 8dede18 | 2015-11-05 16:11:12 +0100 | [diff] [blame] | 99 | #endif |
| 100 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | #endif |
Pierre Ossman | da7fbe5 | 2006-12-24 22:46:55 +0100 | [diff] [blame] | 102 | |