blob: 0fa86a2afc265e7224520f22892e12cfc652a2e2 [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 {
19 void (*remove)(struct mmc_host *);
20 void (*detect)(struct mmc_host *);
Ulf Hansson810cadd2013-06-10 17:03:37 +020021 int (*pre_suspend)(struct mmc_host *);
Nicolas Pitre95cdfb72009-09-22 16:45:29 -070022 int (*suspend)(struct mmc_host *);
23 int (*resume)(struct mmc_host *);
Ulf Hansson12d01d02013-05-02 14:02:37 +020024 int (*runtime_suspend)(struct mmc_host *);
25 int (*runtime_resume)(struct mmc_host *);
Ohad Ben-Cohen12ae6372010-10-02 13:54:06 +020026 int (*power_save)(struct mmc_host *);
27 int (*power_restore)(struct mmc_host *);
Adrian Hunterd3049502011-11-28 16:22:00 +020028 int (*alive)(struct mmc_host *);
Ulf Hansson6b086bd2013-06-10 17:03:41 +020029 int (*shutdown)(struct mmc_host *);
Johan Rudholmf855a372015-01-12 15:38:05 +010030 int (*reset)(struct mmc_host *);
Pierre Ossman7ea239d2006-12-31 00:11:32 +010031};
32
33void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops);
34void mmc_detach_bus(struct mmc_host *host);
35
Sascha Hauer25185f32014-06-30 11:07:25 +020036struct device_node *mmc_of_find_child_device(struct mmc_host *host,
37 unsigned func_num);
38
Adrian Hunterdfe86cb2010-08-11 14:17:46 -070039void mmc_init_erase(struct mmc_card *card);
40
Pierre Ossmanda7fbe52006-12-24 22:46:55 +010041void mmc_set_chip_select(struct mmc_host *host, int mode);
Pierre Ossman7ea239d2006-12-31 00:11:32 +010042void mmc_set_clock(struct mmc_host *host, unsigned int hz);
43void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode);
44void mmc_set_bus_width(struct mmc_host *host, unsigned int width);
45u32 mmc_select_voltage(struct mmc_host *host, u32 ocr);
Ulf Hansson0f791fd2013-09-12 15:36:34 +020046int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, u32 ocr);
Johan Rudholm567c8902013-01-28 15:08:27 +010047int __mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage);
Pierre Ossman7ea239d2006-12-31 00:11:32 +010048void mmc_set_timing(struct mmc_host *host, unsigned int timing);
Arindam Nathd6d50a12011-05-05 12:18:59 +053049void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type);
Adrian Huntere23350b2015-02-06 14:12:55 +020050int mmc_select_drive_strength(struct mmc_card *card, unsigned int max_dtr,
51 int card_drv_type, int *drv_type);
Ulf Hansson4a065192013-09-12 14:36:53 +020052void mmc_power_up(struct mmc_host *host, u32 ocr);
Ulf Hansson7f7e4122011-09-21 14:08:13 -040053void mmc_power_off(struct mmc_host *host);
Ulf Hansson4a065192013-09-12 14:36:53 +020054void mmc_power_cycle(struct mmc_host *host, u32 ocr);
Johan Rudholm2d079c42014-11-06 14:46:54 +010055void mmc_set_initial_state(struct mmc_host *host);
Pierre Ossman7ea239d2006-12-31 00:11:32 +010056
Pierre Ossmanda7fbe52006-12-24 22:46:55 +010057static 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 Ossmanb93931a2007-05-19 14:06:24 +020067void mmc_rescan(struct work_struct *work);
68void mmc_start_host(struct mmc_host *host);
69void mmc_stop_host(struct mmc_host *host);
70
Adrian Hunterd3049502011-11-28 16:22:00 +020071int _mmc_detect_card_removed(struct mmc_host *host);
72
Andy Ross807e8e42011-01-03 10:36:56 -080073int mmc_attach_mmc(struct mmc_host *host);
74int mmc_attach_sd(struct mmc_host *host);
75int mmc_attach_sdio(struct mmc_host *host);
Adrian Bunk98b843b2008-04-13 21:15:50 +030076
Ben Hutchingsbd68e082009-12-14 18:01:29 -080077/* Module parameters */
Rusty Russell90ab5ee2012-01-13 09:32:20 +103078extern bool use_spi_crc;
David Brownellaf517152007-08-08 09:11:32 -070079
Haavard Skinnemoen6edd8ee2008-07-24 14:18:57 +020080/* Debugfs information for hosts and cards */
81void mmc_add_host_debugfs(struct mmc_host *host);
82void mmc_remove_host_debugfs(struct mmc_host *host);
83
Haavard Skinnemoenf4b7f922008-07-24 14:18:58 +020084void mmc_add_card_debugfs(struct mmc_card *card);
85void mmc_remove_card_debugfs(struct mmc_card *card);
86
Konstantin Dorfman2220eed2013-01-14 14:28:17 -050087void mmc_init_context_info(struct mmc_host *host);
Adrian Hunter63e415c2014-12-05 19:40:59 +020088
89int mmc_execute_tuning(struct mmc_card *card);
Adrian Hunter6376f692015-05-07 13:10:20 +030090int mmc_hs200_to_hs400(struct mmc_card *card);
91int mmc_hs400_to_hs200(struct mmc_card *card);
Adrian Hunter63e415c2014-12-05 19:40:59 +020092
Ulf Hansson8dede182015-11-05 16:11:12 +010093#ifdef CONFIG_PM_SLEEP
94void mmc_register_pm_notifier(struct mmc_host *host);
95void mmc_unregister_pm_notifier(struct mmc_host *host);
96#else
Arnd Bergmannfb0229d2015-11-20 11:28:42 +010097static inline void mmc_register_pm_notifier(struct mmc_host *host) { }
98static inline void mmc_unregister_pm_notifier(struct mmc_host *host) { }
Ulf Hansson8dede182015-11-05 16:11:12 +010099#endif
100
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101#endif
Pierre Ossmanda7fbe52006-12-24 22:46:55 +0100102