aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mmc/core/core.c63
-rw-r--r--drivers/mmc/core/core.h22
-rw-r--r--drivers/mmc/core/sd_ops.c58
-rw-r--r--drivers/mmc/core/sd_ops.h1
4 files changed, 69 insertions, 75 deletions
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index d08968470c41..bfd2ae5bd669 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -102,15 +102,7 @@ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq)
102 102
103EXPORT_SYMBOL(mmc_request_done); 103EXPORT_SYMBOL(mmc_request_done);
104 104
105/** 105static void
106 * mmc_start_request - start a command on a host
107 * @host: MMC host to start command on
108 * @mrq: MMC request to start
109 *
110 * Queue a command on the specified host. We expect the
111 * caller to be holding the host lock with interrupts disabled.
112 */
113void
114mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) 106mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
115{ 107{
116#ifdef CONFIG_MMC_DEBUG 108#ifdef CONFIG_MMC_DEBUG
@@ -165,8 +157,6 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
165 host->ops->request(host, mrq); 157 host->ops->request(host, mrq);
166} 158}
167 159
168EXPORT_SYMBOL(mmc_start_request);
169
170static void mmc_wait_done(struct mmc_request *mrq) 160static void mmc_wait_done(struct mmc_request *mrq)
171{ 161{
172 complete(mrq->done_data); 162 complete(mrq->done_data);
@@ -472,6 +462,45 @@ static void mmc_power_off(struct mmc_host *host)
472} 462}
473 463
474/* 464/*
465 * Cleanup when the last reference to the bus operator is dropped.
466 */
467void __mmc_release_bus(struct mmc_host *host)
468{
469 BUG_ON(!host);
470 BUG_ON(host->bus_refs);
471 BUG_ON(!host->bus_dead);
472
473 host->bus_ops = NULL;
474}
475
476/*
477 * Increase reference count of bus operator
478 */
479static inline void mmc_bus_get(struct mmc_host *host)
480{
481 unsigned long flags;
482
483 spin_lock_irqsave(&host->lock, flags);
484 host->bus_refs++;
485 spin_unlock_irqrestore(&host->lock, flags);
486}
487
488/*
489 * Decrease reference count of bus operator and free it if
490 * it is the last reference.
491 */
492static inline void mmc_bus_put(struct mmc_host *host)
493{
494 unsigned long flags;
495
496 spin_lock_irqsave(&host->lock, flags);
497 host->bus_refs--;
498 if ((host->bus_refs == 0) && host->bus_ops)
499 __mmc_release_bus(host);
500 spin_unlock_irqrestore(&host->lock, flags);
501}
502
503/*
475 * Assign a mmc bus handler to a host. Only one bus handler may control a 504 * Assign a mmc bus handler to a host. Only one bus handler may control a
476 * host at any given time. 505 * host at any given time.
477 */ 506 */
@@ -520,18 +549,6 @@ void mmc_detach_bus(struct mmc_host *host)
520 mmc_bus_put(host); 549 mmc_bus_put(host);
521} 550}
522 551
523/*
524 * Cleanup when the last reference to the bus operator is dropped.
525 */
526void __mmc_release_bus(struct mmc_host *host)
527{
528 BUG_ON(!host);
529 BUG_ON(host->bus_refs);
530 BUG_ON(!host->bus_dead);
531
532 host->bus_ops = NULL;
533}
534
535/** 552/**
536 * mmc_detect_change - process change of state on a MMC socket 553 * mmc_detect_change - process change of state on a MMC socket
537 * @host: host which changed state. 554 * @host: host which changed state.
diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
index ae006b30dd86..bb2774af9ea9 100644
--- a/drivers/mmc/core/core.h
+++ b/drivers/mmc/core/core.h
@@ -27,28 +27,6 @@ struct mmc_bus_ops {
27void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops); 27void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops);
28void mmc_detach_bus(struct mmc_host *host); 28void mmc_detach_bus(struct mmc_host *host);
29 29
30void __mmc_release_bus(struct mmc_host *host);
31
32static inline void mmc_bus_get(struct mmc_host *host)
33{
34 unsigned long flags;
35
36 spin_lock_irqsave(&host->lock, flags);
37 host->bus_refs++;
38 spin_unlock_irqrestore(&host->lock, flags);
39}
40
41static inline void mmc_bus_put(struct mmc_host *host)
42{
43 unsigned long flags;
44
45 spin_lock_irqsave(&host->lock, flags);
46 host->bus_refs--;
47 if ((host->bus_refs == 0) && host->bus_ops)
48 __mmc_release_bus(host);
49 spin_unlock_irqrestore(&host->lock, flags);
50}
51
52void mmc_set_chip_select(struct mmc_host *host, int mode); 30void mmc_set_chip_select(struct mmc_host *host, int mode);
53void mmc_set_clock(struct mmc_host *host, unsigned int hz); 31void mmc_set_clock(struct mmc_host *host, unsigned int hz);
54void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode); 32void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode);
diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c
index ee9a1b9f5998..342f340ebc25 100644
--- a/drivers/mmc/core/sd_ops.c
+++ b/drivers/mmc/core/sd_ops.c
@@ -21,6 +21,35 @@
21#include "core.h" 21#include "core.h"
22#include "sd_ops.h" 22#include "sd_ops.h"
23 23
24static int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card)
25{
26 int err;
27 struct mmc_command cmd;
28
29 BUG_ON(!host);
30 BUG_ON(card && (card->host != host));
31
32 cmd.opcode = MMC_APP_CMD;
33
34 if (card) {
35 cmd.arg = card->rca << 16;
36 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
37 } else {
38 cmd.arg = 0;
39 cmd.flags = MMC_RSP_R1 | MMC_CMD_BCR;
40 }
41
42 err = mmc_wait_for_cmd(host, &cmd, 0);
43 if (err != MMC_ERR_NONE)
44 return err;
45
46 /* Check that card supported application commands */
47 if (!(cmd.resp[0] & R1_APP_CMD))
48 return MMC_ERR_FAILED;
49
50 return MMC_ERR_NONE;
51}
52
24/** 53/**
25 * mmc_wait_for_app_cmd - start an application command and wait for 54 * mmc_wait_for_app_cmd - start an application command and wait for
26 completion 55 completion
@@ -77,35 +106,6 @@ int mmc_wait_for_app_cmd(struct mmc_host *host, struct mmc_card *card,
77 106
78EXPORT_SYMBOL(mmc_wait_for_app_cmd); 107EXPORT_SYMBOL(mmc_wait_for_app_cmd);
79 108
80int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card)
81{
82 int err;
83 struct mmc_command cmd;
84
85 BUG_ON(!host);
86 BUG_ON(card && (card->host != host));
87
88 cmd.opcode = MMC_APP_CMD;
89
90 if (card) {
91 cmd.arg = card->rca << 16;
92 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
93 } else {
94 cmd.arg = 0;
95 cmd.flags = MMC_RSP_R1 | MMC_CMD_BCR;
96 }
97
98 err = mmc_wait_for_cmd(host, &cmd, 0);
99 if (err != MMC_ERR_NONE)
100 return err;
101
102 /* Check that card supported application commands */
103 if (!(cmd.resp[0] & R1_APP_CMD))
104 return MMC_ERR_FAILED;
105
106 return MMC_ERR_NONE;
107}
108
109int mmc_app_set_bus_width(struct mmc_card *card, int width) 109int mmc_app_set_bus_width(struct mmc_card *card, int width)
110{ 110{
111 int err; 111 int err;
diff --git a/drivers/mmc/core/sd_ops.h b/drivers/mmc/core/sd_ops.h
index 09ca52fca2f6..9742d8a30664 100644
--- a/drivers/mmc/core/sd_ops.h
+++ b/drivers/mmc/core/sd_ops.h
@@ -12,7 +12,6 @@
12#ifndef _MMC_SD_OPS_H 12#ifndef _MMC_SD_OPS_H
13#define _MMC_SD_OPS_H 13#define _MMC_SD_OPS_H
14 14
15int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card);
16int mmc_app_set_bus_width(struct mmc_card *card, int width); 15int mmc_app_set_bus_width(struct mmc_card *card, int width);
17int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr); 16int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr);
18int mmc_send_if_cond(struct mmc_host *host, u32 ocr); 17int mmc_send_if_cond(struct mmc_host *host, u32 ocr);