Lines Matching refs:cmd

581 amlmmc_exec_command(sdmmc_chipset_handle_t sch, struct sdmmc_command *cmd)  in amlmmc_exec_command()  argument
591 cmd_cfg = cmd->c_opcode << SD_EMMC_CMD_CFG_CMD_INDEX_SHIFT; in amlmmc_exec_command()
592 if (!ISSET(cmd->c_flags, SCF_RSP_PRESENT)) in amlmmc_exec_command()
594 if (ISSET(cmd->c_flags, SCF_RSP_136)) in amlmmc_exec_command()
596 if (ISSET(cmd->c_flags, SCF_RSP_BSY)) in amlmmc_exec_command()
598 if (!ISSET(cmd->c_flags, SCF_RSP_CRC)) in amlmmc_exec_command()
600 if (cmd->c_datalen > 0) { in amlmmc_exec_command()
602 if (cmd->c_datalen >= cmd->c_blklen) in amlmmc_exec_command()
604 if (!ISSET(cmd->c_flags, SCF_CMD_READ)) in amlmmc_exec_command()
613 if (cmd->c_datalen > 0 && in amlmmc_exec_command()
614 cmd->c_dmamap && cmd->c_dmamap->dm_nsegs > 1) { in amlmmc_exec_command()
618 for (seg = 0; seg < cmd->c_dmamap->dm_nsegs; seg++) { in amlmmc_exec_command()
619 bus_addr_t addr = cmd->c_dmamap->dm_segs[seg].ds_addr; in amlmmc_exec_command()
620 bus_size_t len = cmd->c_dmamap->dm_segs[seg].ds_len; in amlmmc_exec_command()
622 if (seg == cmd->c_dmamap->dm_nsegs - 1) in amlmmc_exec_command()
626 desc[seg].cmd_cfg = cmd_cfg | (len / cmd->c_blklen); in amlmmc_exec_command()
627 desc[seg].cmd_arg = cmd->c_arg; in amlmmc_exec_command()
634 cmd->c_dmamap->dm_nsegs * sizeof(struct amlmmc_desc), in amlmmc_exec_command()
642 if (cmd->c_datalen > 0 && !cmd->c_dmamap) { in amlmmc_exec_command()
644 KASSERT(cmd->c_datalen <= PAGE_SIZE); in amlmmc_exec_command()
645 if (ISSET(cmd->c_flags, SCF_CMD_READ)) { in amlmmc_exec_command()
647 cmd->c_datalen, BUS_DMASYNC_PREREAD); in amlmmc_exec_command()
649 memcpy(sc->sc_desc, cmd->c_data, cmd->c_datalen); in amlmmc_exec_command()
651 cmd->c_datalen, BUS_DMASYNC_PREWRITE); in amlmmc_exec_command()
655 if (cmd->c_datalen > 0) { in amlmmc_exec_command()
656 if (cmd->c_datalen >= cmd->c_blklen) { in amlmmc_exec_command()
657 amlmmc_set_blklen(sc, cmd->c_blklen); in amlmmc_exec_command()
658 cmd_cfg |= cmd->c_datalen / cmd->c_blklen; in amlmmc_exec_command()
660 cmd_cfg |= cmd->c_datalen; in amlmmc_exec_command()
663 if (cmd->c_dmamap) in amlmmc_exec_command()
664 data_addr = cmd->c_dmamap->dm_segs[0].ds_addr; in amlmmc_exec_command()
677 HWRITE4(sc, SD_EMMC_CMD_ARG, cmd->c_arg); in amlmmc_exec_command()
690 cmd->c_error = ETIMEDOUT; in amlmmc_exec_command()
692 cmd->c_error = ETIMEDOUT; in amlmmc_exec_command()
694 cmd->c_error = ETIMEDOUT; in amlmmc_exec_command()
696 cmd->c_error = EIO; in amlmmc_exec_command()
698 if (ISSET(cmd->c_flags, SCF_RSP_PRESENT)) { in amlmmc_exec_command()
699 if (ISSET(cmd->c_flags, SCF_RSP_136)) { in amlmmc_exec_command()
700 cmd->c_resp[0] = HREAD4(sc, SD_EMMC_CMD_RSP); in amlmmc_exec_command()
701 cmd->c_resp[1] = HREAD4(sc, SD_EMMC_CMD_RSP1); in amlmmc_exec_command()
702 cmd->c_resp[2] = HREAD4(sc, SD_EMMC_CMD_RSP2); in amlmmc_exec_command()
703 cmd->c_resp[3] = HREAD4(sc, SD_EMMC_CMD_RSP3); in amlmmc_exec_command()
704 if (ISSET(cmd->c_flags, SCF_RSP_CRC)) { in amlmmc_exec_command()
705 cmd->c_resp[0] = (cmd->c_resp[0] >> 8) | in amlmmc_exec_command()
706 (cmd->c_resp[1] << 24); in amlmmc_exec_command()
707 cmd->c_resp[1] = (cmd->c_resp[1] >> 8) | in amlmmc_exec_command()
708 (cmd->c_resp[2] << 24); in amlmmc_exec_command()
709 cmd->c_resp[2] = (cmd->c_resp[2] >> 8) | in amlmmc_exec_command()
710 (cmd->c_resp[3] << 24); in amlmmc_exec_command()
711 cmd->c_resp[3] = (cmd->c_resp[3] >> 8); in amlmmc_exec_command()
714 cmd->c_resp[0] = HREAD4(sc, SD_EMMC_CMD_RSP); in amlmmc_exec_command()
719 if (cmd->c_datalen > 0 && !cmd->c_dmamap) { in amlmmc_exec_command()
720 if (ISSET(cmd->c_flags, SCF_CMD_READ)) { in amlmmc_exec_command()
722 cmd->c_datalen, BUS_DMASYNC_POSTREAD); in amlmmc_exec_command()
723 memcpy(cmd->c_data, sc->sc_desc, cmd->c_datalen); in amlmmc_exec_command()
726 cmd->c_datalen, BUS_DMASYNC_POSTWRITE); in amlmmc_exec_command()
731 if (cmd->c_datalen > 0 && in amlmmc_exec_command()
732 cmd->c_dmamap && cmd->c_dmamap->dm_nsegs > 1) { in amlmmc_exec_command()
735 cmd->c_dmamap->dm_nsegs * sizeof(struct amlmmc_desc), in amlmmc_exec_command()
739 SET(cmd->c_flags, SCF_ITSDONE); in amlmmc_exec_command()
772 struct sdmmc_command cmd; in amlmmc_execute_tuning() local
801 memset(&cmd, 0, sizeof(cmd)); in amlmmc_execute_tuning()
802 cmd.c_opcode = opcode; in amlmmc_execute_tuning()
803 cmd.c_arg = 0; in amlmmc_execute_tuning()
804 cmd.c_flags = SCF_CMD_ADTC | SCF_CMD_READ | SCF_RSP_R1; in amlmmc_execute_tuning()
806 cmd.c_blklen = cmd.c_datalen = 128; in amlmmc_execute_tuning()
808 cmd.c_blklen = cmd.c_datalen = 64; in amlmmc_execute_tuning()
810 cmd.c_data = data; in amlmmc_execute_tuning()
812 amlmmc_exec_command(sch, &cmd); in amlmmc_execute_tuning()
813 if (cmd.c_error == 0) in amlmmc_execute_tuning()