Pierre Ossman | 5c4e6f1 | 2007-05-21 20:23:20 +0200 | [diff] [blame^] | 1 | /* |
| 2 | * linux/drivers/mmc/sdio_ops.c |
| 3 | * |
| 4 | * Copyright 2006-2007 Pierre Ossman |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or (at |
| 9 | * your option) any later version. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/mmc/host.h> |
| 13 | #include <linux/mmc/mmc.h> |
| 14 | #include <linux/mmc/sdio.h> |
| 15 | |
| 16 | #include "core.h" |
| 17 | |
| 18 | int mmc_send_io_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) |
| 19 | { |
| 20 | struct mmc_command cmd; |
| 21 | int i, err = 0; |
| 22 | |
| 23 | BUG_ON(!host); |
| 24 | |
| 25 | memset(&cmd, 0, sizeof(struct mmc_command)); |
| 26 | |
| 27 | cmd.opcode = SD_IO_SEND_OP_COND; |
| 28 | cmd.arg = ocr; |
| 29 | cmd.flags = MMC_RSP_R4 | MMC_CMD_BCR; |
| 30 | |
| 31 | for (i = 100; i; i--) { |
| 32 | err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES); |
| 33 | if (err) |
| 34 | break; |
| 35 | |
| 36 | if (cmd.resp[0] & MMC_CARD_BUSY || ocr == 0) |
| 37 | break; |
| 38 | |
| 39 | err = -ETIMEDOUT; |
| 40 | |
| 41 | mmc_delay(10); |
| 42 | } |
| 43 | |
| 44 | if (rocr) |
| 45 | *rocr = cmd.resp[0]; |
| 46 | |
| 47 | return err; |
| 48 | } |
| 49 | |