Lines Matching defs:handle

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