sdio_ops.c 959 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. #include <linux/mmc/host.h>
  12. #include <linux/mmc/mmc.h>
  13. #include <linux/mmc/sdio.h>
  14. #include "core.h"
  15. int mmc_send_io_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
  16. {
  17. struct mmc_command cmd;
  18. int i, err = 0;
  19. BUG_ON(!host);
  20. memset(&cmd, 0, sizeof(struct mmc_command));
  21. cmd.opcode = SD_IO_SEND_OP_COND;
  22. cmd.arg = ocr;
  23. cmd.flags = MMC_RSP_R4 | MMC_CMD_BCR;
  24. for (i = 100; i; i--) {
  25. err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
  26. if (err)
  27. break;
  28. if (cmd.resp[0] & MMC_CARD_BUSY || ocr == 0)
  29. break;
  30. err = -ETIMEDOUT;
  31. mmc_delay(10);
  32. }
  33. if (rocr)
  34. *rocr = cmd.resp[0];
  35. return err;
  36. }