Lines Matching refs:handle

19 int sd_cmd0(struct sd_handle *handle)  in sd_cmd0()  argument
25 res = send_cmd(handle, SD_CMD_GO_IDLE_STATE, argument, 0, NULL); in sd_cmd0()
29 chal_sd_clear_irq((void *)handle->device, 0xffffffff); in sd_cmd0()
35 int sd_cmd1(struct sd_handle *handle, uint32_t ocr, uint32_t *ocr_output) in sd_cmd1() argument
49 res = send_cmd(handle, SD_CMD_SEND_OPCOND, ocr, options, &resp); in sd_cmd1()
57 int sd_cmd2(struct sd_handle *handle) in sd_cmd2() argument
65 return send_cmd(handle, SD_CMD_ALL_SEND_CID, 0, options, &resp); in sd_cmd2()
68 int sd_cmd3(struct sd_handle *handle) in sd_cmd3() argument
76 handle->device->ctrl.rca = 0x5; in sd_cmd3()
77 argument = handle->device->ctrl.rca << SD_CMD7_ARG_RCA_SHIFT; in sd_cmd3()
84 res = send_cmd(handle, SD_CMD_MMC_SET_RCA, argument, options, &resp); in sd_cmd3()
87 handle->device->ctrl.rca = 0; in sd_cmd3()
92 int sd_cmd7(struct sd_handle *handle, uint32_t rca) in sd_cmd7() argument
113 res = send_cmd(handle, SD_CMD_SELECT_DESELECT_CARD, argument, options, in sd_cmd7()
118 chal_sd_clear_irq((void *)handle->device, 0xffffffff); in sd_cmd7()
127 int mmc_cmd8(struct sd_handle *handle, uint8_t *extCsdReg) in mmc_cmd8() argument
132 data_xfer_setup(handle, extCsdReg, CEATA_EXT_CSDBLOCK_SIZE, in mmc_cmd8()
140 res = send_cmd(handle, SD_CMD_READ_EXT_CSD, 0, options, &resp); in mmc_cmd8()
143 res = process_data_xfer(handle, extCsdReg, 0, in mmc_cmd8()
150 int sd_cmd9(struct sd_handle *handle, struct sd_card_data *card) in sd_cmd9() argument
157 argument = handle->device->ctrl.rca << SD_CMD7_ARG_RCA_SHIFT; in sd_cmd9()
163 res = send_cmd(handle, SD_CMD_SEND_CSD, argument, options, &resp); in sd_cmd9()
168 if (handle->card->type == SD_CARD_MMC) { in sd_cmd9()
212 handle->card->size = in sd_cmd9()
216 handle->card->maxRdBlkLen = maxReadBlockLen; in sd_cmd9()
217 handle->card->maxWtBlkLen = maxWriteBlockLen; in sd_cmd9()
219 if (handle->card->size < 0xA00000) { in sd_cmd9()
224 handle->card->size = 0x40000000; in sd_cmd9()
225 handle->card->maxRdBlkLen = 512; in sd_cmd9()
226 handle->card->maxWtBlkLen = 512; in sd_cmd9()
229 if ((handle->card->maxRdBlkLen > 512) || in sd_cmd9()
230 (handle->card->maxWtBlkLen > 512)) { in sd_cmd9()
231 handle->card->maxRdBlkLen = 512; in sd_cmd9()
232 handle->card->maxWtBlkLen = 512; in sd_cmd9()
233 } else if ((handle->card->maxRdBlkLen == 0) || in sd_cmd9()
234 (handle->card->maxWtBlkLen == 0)) { in sd_cmd9()
235 handle->card->maxRdBlkLen = 512; in sd_cmd9()
236 handle->card->maxWtBlkLen = 512; in sd_cmd9()
239 handle->device->cfg.blockSize = handle->card->maxRdBlkLen; in sd_cmd9()
244 int sd_cmd13(struct sd_handle *handle, uint32_t *status) in sd_cmd13() argument
250 argument = handle->device->ctrl.rca << SD_CMD7_ARG_RCA_SHIFT; in sd_cmd13()
257 res = send_cmd(handle, SD_CMD_SEND_STATUS, argument, options, &resp); in sd_cmd13()
266 int sd_cmd16(struct sd_handle *handle, uint32_t length) in sd_cmd16() argument
280 res = sd_cmd13(handle, &resp.cardStatus); in sd_cmd16()
284 handle->device->ctrl.rca, res, resp.cardStatus); in sd_cmd16()
293 if (ntry > handle->device->cfg.retryLimit) { in sd_cmd16()
295 handle->device->cfg.retryLimit); in sd_cmd16()
307 res = send_cmd(handle, SD_CMD_SET_BLOCKLEN, argument, options, &resp); in sd_cmd16()
312 int sd_cmd17(struct sd_handle *handle, in sd_cmd17() argument
321 res = sd_cmd13(handle, &resp.cardStatus); in sd_cmd17()
325 handle->device->ctrl.rca, res, resp.cardStatus); in sd_cmd17()
334 if (ntry > handle->device->cfg.retryLimit) { in sd_cmd17()
336 handle->device->cfg.retryLimit); in sd_cmd17()
347 data_xfer_setup(handle, buffer, len, SD_XFER_CARD_TO_HOST); in sd_cmd17()
355 res = send_cmd(handle, SD_CMD_READ_SINGLE_BLOCK, argument, options, in sd_cmd17()
361 res = process_data_xfer(handle, buffer, addr, len, SD_XFER_CARD_TO_HOST); in sd_cmd17()
366 int sd_cmd18(struct sd_handle *handle, in sd_cmd18() argument
375 res = sd_cmd13(handle, &resp.cardStatus); in sd_cmd18()
379 handle->device->ctrl.rca, res, resp.cardStatus); in sd_cmd18()
388 if (ntry > handle->device->cfg.retryLimit) { in sd_cmd18()
390 handle->device->cfg.retryLimit); in sd_cmd18()
400 data_xfer_setup(handle, buffer, len, SD_XFER_CARD_TO_HOST); in sd_cmd18()
411 res = send_cmd(handle, SD_CMD_READ_MULTIPLE_BLOCK, argument, options, in sd_cmd18()
417 res = process_data_xfer(handle, buffer, addr, len, SD_XFER_CARD_TO_HOST); in sd_cmd18()
423 static int card_sts_resp(struct sd_handle *handle, uint32_t *status) in card_sts_resp() argument
429 res = sd_cmd13(handle, status); in card_sts_resp()
433 handle->device->ctrl.rca, res); in card_sts_resp()
442 if (ntry > handle->device->cfg.retryLimit) { in card_sts_resp()
444 handle->device->cfg.retryLimit); in card_sts_resp()
457 int sd_cmd35(struct sd_handle *handle, uint32_t start) in sd_cmd35() argument
463 res = card_sts_resp(handle, &resp.cardStatus); in sd_cmd35()
474 res = send_cmd(handle, SD_CMD_ERASE_GROUP_START, in sd_cmd35()
483 int sd_cmd36(struct sd_handle *handle, uint32_t end) in sd_cmd36() argument
489 res = card_sts_resp(handle, &resp.cardStatus); in sd_cmd36()
500 res = send_cmd(handle, SD_CMD_ERASE_GROUP_END, in sd_cmd36()
509 int sd_cmd38(struct sd_handle *handle) in sd_cmd38() argument
515 res = card_sts_resp(handle, &resp.cardStatus); in sd_cmd38()
526 res = send_cmd(handle, SD_CMD_ERASE, argument, options, &resp); in sd_cmd38()
537 int sd_cmd24(struct sd_handle *handle, in sd_cmd24() argument
546 res = sd_cmd13(handle, &resp.cardStatus); in sd_cmd24()
550 handle->device->ctrl.rca, res, &resp.cardStatus); in sd_cmd24()
559 if (ntry > handle->device->cfg.retryLimit) { in sd_cmd24()
561 handle->device->cfg.retryLimit); in sd_cmd24()
572 data_xfer_setup(handle, buffer, len, SD_XFER_HOST_TO_CARD); in sd_cmd24()
581 res = send_cmd(handle, SD_CMD_WRITE_BLOCK, argument, options, &resp); in sd_cmd24()
586 res = process_data_xfer(handle, buffer, addr, len, SD_XFER_HOST_TO_CARD); in sd_cmd24()
591 int sd_cmd25(struct sd_handle *handle, in sd_cmd25() argument
600 res = sd_cmd13(handle, &resp.cardStatus); in sd_cmd25()
604 handle->device->ctrl.rca, res, &resp.cardStatus); in sd_cmd25()
613 if (ntry > handle->device->cfg.retryLimit) { in sd_cmd25()
615 handle->device->cfg.retryLimit); in sd_cmd25()
625 data_xfer_setup(handle, buffer, len, SD_XFER_HOST_TO_CARD); in sd_cmd25()
636 res = send_cmd(handle, SD_CMD_WRITE_MULTIPLE_BLOCK, in sd_cmd25()
642 res = process_data_xfer(handle, buffer, addr, len, SD_XFER_HOST_TO_CARD); in sd_cmd25()
648 int mmc_cmd6(struct sd_handle *handle, uint32_t argument) in mmc_cmd6() argument
660 res = send_cmd(handle, SD_ACMD_SET_BUS_WIDTH, argument, options, &resp); in mmc_cmd6()
670 wait_for_event(handle, in mmc_cmd6()
672 handle->device->cfg.wfe_retry); in mmc_cmd6()
678 res = sd_cmd13(handle, &resp.cardStatus); in mmc_cmd6()
689 handle->device->ctrl.rca, res, resp.cardStatus); in mmc_cmd6()
701 int send_cmd(struct sd_handle *handle, uint32_t cmdIndex, uint32_t argument, in send_cmd() argument
708 if (handle == NULL) { in send_cmd()
719 chal_sd_get_present_status((CHAL_HANDLE *) handle->device); in send_cmd()
736 check_error(handle, SD4_EMMC_TOP_INTR_CMDERROR_MASK); in send_cmd()
738 handle->device->ctrl.argReg = argument; in send_cmd()
739 chal_sd_send_cmd((CHAL_HANDLE *) handle->device, cmdIndex, in send_cmd()
740 handle->device->ctrl.argReg, options); in send_cmd()
742 handle->device->ctrl.cmdIndex = cmdIndex; in send_cmd()
744 event = wait_for_event(handle, in send_cmd()
747 handle->device->cfg.wfe_retry); in send_cmd()
749 if (handle->device->ctrl.cmdStatus == SD_CMD_MISSING) { in send_cmd()
752 if (retry >= handle->device->cfg.retryLimit) { in send_cmd()
759 handle->device); in send_cmd()
762 check_error(handle, in send_cmd()
768 handle->device)); in send_cmd()
773 if (handle->device->ctrl.cmdStatus == SD_OK) { in send_cmd()
776 chal_sd_get_response((CHAL_HANDLE *) handle->device, in send_cmd()
778 process_cmd_response(handle, in send_cmd()
779 handle->device->ctrl.cmdIndex, in send_cmd()
792 handle->device); in send_cmd()
808 } else if (handle->device->ctrl.cmdStatus && in send_cmd()
809 handle->device->ctrl.cmdStatus != SD_CMD_MISSING) { in send_cmd()
811 status = check_error(handle, handle->device->ctrl.cmdStatus); in send_cmd()
815 cmdIndex, handle->device->ctrl.cmdStatus, status); in send_cmd()
817 if ((handle->device->ctrl.cmdIndex == 1) || in send_cmd()
818 (handle->device->ctrl.cmdIndex == 5)) { in send_cmd()
820 } else if ((handle->device->ctrl.cmdIndex == 7) || in send_cmd()
821 (handle->device->ctrl.cmdIndex == 41)) { in send_cmd()
824 (retry < handle->device->cfg.retryLimit)) { in send_cmd()
828 handle->device)); in send_cmd()
837 handle->device->ctrl.blkReg = 0; in send_cmd()
839 handle->device->ctrl.cmdStatus = 0; in send_cmd()