Lines Matching refs:sata
102 fsl_sata_t *sata; in init_sata() local
121 sata = (fsl_sata_t *)malloc(sizeof(fsl_sata_t)); in init_sata()
122 if (!sata) { in init_sata()
127 memset((void *)sata, 0, sizeof(fsl_sata_t)); in init_sata()
129 snprintf(sata->name, 12, "SATA%d:", dev); in init_sata()
133 sata_dev_desc[dev].priv = (void *)sata; in init_sata()
135 sata->dma_flag = fsl_sata_info[dev].flags; in init_sata()
138 sata->dma_flag = priv->flag; in init_sata()
139 priv->fsl_sata = sata; in init_sata()
141 sata->reg_base = reg; in init_sata()
146 sata->cmd_hdr_tbl_offset = (void *)malloc(length + align); in init_sata()
147 if (!sata->cmd_hdr_tbl_offset) { in init_sata()
152 cmd_hdr = (cmd_hdr_tbl_t *)(((u32)sata->cmd_hdr_tbl_offset + align) in init_sata()
154 sata->cmd_hdr = cmd_hdr; in init_sata()
157 memset((void *)sata->cmd_hdr_tbl_offset, 0, length + align); in init_sata()
162 sata->cmd_desc_offset = (void *)malloc(length + align); in init_sata()
163 if (!sata->cmd_desc_offset) { in init_sata()
167 sata->cmd_desc = (cmd_desc_t *)(((u32)sata->cmd_desc_offset + align) in init_sata()
170 memset((void *)sata->cmd_desc_offset, 0, length + align); in init_sata()
174 cda = ((u32)sata->cmd_desc + SATA_HC_CMD_DESC_SIZE * i) in init_sata()
240 printf("%s ", sata->name); in init_sata()
249 sata->link = 1; in init_sata()
251 sata->link = 0; in init_sata()
263 sata->ata_device_type = ata_dev_classify(sig); in init_sata()
311 static int fsl_ata_exec_ata_cmd(struct fsl_sata *sata, struct sata_fis_h2d *cfis, in fsl_ata_exec_ata_cmd() argument
322 fsl_sata_reg_t __iomem *reg = sata->reg_base; in fsl_ata_exec_ata_cmd()
332 cmd_desc = sata->cmd_desc + tag; in fsl_ata_exec_ata_cmd()
396 cmd_hdr = (cmd_hdr_entry_t *)&sata->cmd_hdr->cmd_slot[tag]; in fsl_ata_exec_ata_cmd()
462 static int fsl_ata_exec_reset_cmd(struct fsl_sata *sata, struct sata_fis_h2d *cfis, in fsl_ata_exec_reset_cmd() argument
468 static int fsl_sata_exec_cmd(struct fsl_sata *sata, struct sata_fis_h2d *cfis, in fsl_sata_exec_cmd() argument
480 rc = fsl_ata_exec_ata_cmd(sata, cfis, 0, tag, buffer, len); in fsl_sata_exec_cmd()
483 rc = fsl_ata_exec_reset_cmd(sata, cfis, tag, buffer, len); in fsl_sata_exec_cmd()
486 rc = fsl_ata_exec_ata_cmd(sata, cfis, 1, tag, buffer, len); in fsl_sata_exec_cmd()
500 static void fsl_sata_xfer_mode(fsl_sata_t *sata, u16 *id) in fsl_sata_xfer_mode() argument
502 sata->pio = id[ATA_ID_PIO_MODES]; in fsl_sata_xfer_mode()
503 sata->mwdma = id[ATA_ID_MWDMA_MODES]; in fsl_sata_xfer_mode()
504 sata->udma = id[ATA_ID_UDMA_MODES]; in fsl_sata_xfer_mode()
505 debug("pio %04x, mwdma %04x, udma %04x\n\r", sata->pio, sata->mwdma, sata->udma); in fsl_sata_xfer_mode()
508 static void fsl_sata_set_features(fsl_sata_t *sata) in fsl_sata_set_features() argument
521 udma_cap = (u8)(sata->udma & 0xff); in fsl_sata_set_features()
533 fsl_sata_exec_cmd(sata, cfis, CMD_ATA, 0, NULL, 0); in fsl_sata_set_features()
536 static u32 fsl_sata_rw_cmd(fsl_sata_t *sata, u32 start, u32 blkcnt, u8 *buffer, in fsl_sata_rw_cmd() argument
557 fsl_sata_exec_cmd(sata, cfis, CMD_ATA, 0, buffer, ATA_SECT_SIZE * blkcnt); in fsl_sata_rw_cmd()
561 static void fsl_sata_flush_cache(fsl_sata_t *sata) in fsl_sata_flush_cache() argument
571 fsl_sata_exec_cmd(sata, cfis, CMD_ATA, 0, NULL, 0); in fsl_sata_flush_cache()
574 static u32 fsl_sata_rw_cmd_ext(fsl_sata_t *sata, u32 start, u32 blkcnt, in fsl_sata_rw_cmd_ext() argument
600 fsl_sata_exec_cmd(sata, cfis, CMD_ATA, 0, buffer, ATA_SECT_SIZE * blkcnt); in fsl_sata_rw_cmd_ext()
604 static u32 fsl_sata_rw_ncq_cmd(fsl_sata_t *sata, u32 start, u32 blkcnt, in fsl_sata_rw_ncq_cmd() argument
611 if (sata->lba48 != 1) { in fsl_sata_rw_ncq_cmd()
637 if (sata->queue_depth >= SATA_HC_MAX_CMD) in fsl_sata_rw_ncq_cmd()
640 ncq_channel = sata->queue_depth - 1; in fsl_sata_rw_ncq_cmd()
643 fsl_sata_exec_cmd(sata, cfis, CMD_NCQ, ncq_channel, buffer, ATA_SECT_SIZE * blkcnt); in fsl_sata_rw_ncq_cmd()
647 static void fsl_sata_flush_cache_ext(fsl_sata_t *sata) in fsl_sata_flush_cache_ext() argument
657 fsl_sata_exec_cmd(sata, cfis, CMD_ATA, 0, NULL, 0); in fsl_sata_flush_cache_ext()
660 static void fsl_sata_init_wcache(fsl_sata_t *sata, u16 *id) in fsl_sata_init_wcache() argument
663 sata->wcache = 1; in fsl_sata_init_wcache()
665 sata->flush = 1; in fsl_sata_init_wcache()
667 sata->flush_ext = 1; in fsl_sata_init_wcache()
670 static u32 ata_low_level_rw_lba48(fsl_sata_t *sata, u32 blknr, lbaint_t blkcnt, in ata_low_level_rw_lba48() argument
684 if (sata->dma_flag != FLAGS_FPDMA) in ata_low_level_rw_lba48()
685 fsl_sata_rw_cmd_ext(sata, start, max_blks, addr, in ata_low_level_rw_lba48()
688 fsl_sata_rw_ncq_cmd(sata, start, max_blks, addr, in ata_low_level_rw_lba48()
694 if (sata->dma_flag != FLAGS_FPDMA) in ata_low_level_rw_lba48()
695 fsl_sata_rw_cmd_ext(sata, start, blks, addr, in ata_low_level_rw_lba48()
698 fsl_sata_rw_ncq_cmd(sata, start, blks, addr, in ata_low_level_rw_lba48()
709 static u32 ata_low_level_rw_lba28(fsl_sata_t *sata, u32 blknr, u32 blkcnt, in ata_low_level_rw_lba28() argument
723 fsl_sata_rw_cmd(sata, start, max_blks, addr, is_write); in ata_low_level_rw_lba28()
728 fsl_sata_rw_cmd(sata, start, blks, addr, is_write); in ata_low_level_rw_lba28()
744 fsl_sata_t *sata = (fsl_sata_t *)sata_dev_desc[dev].priv; local
750 fsl_sata_t *sata = priv->fsl_sata;
754 if (sata->lba48)
755 rc = ata_low_level_rw_lba48(sata, blknr, blkcnt, buffer,
758 rc = ata_low_level_rw_lba28(sata, blknr, blkcnt, buffer,
766 fsl_sata_t *sata = (fsl_sata_t *)sata_dev_desc[dev].priv; local
772 fsl_sata_t *sata = priv->fsl_sata;
776 if (sata->lba48) {
777 rc = ata_low_level_rw_lba48(sata, blknr, blkcnt, buffer,
779 if (sata->wcache && sata->flush_ext)
780 fsl_sata_flush_cache_ext(sata);
782 rc = ata_low_level_rw_lba28(sata, blknr, blkcnt, buffer,
784 if (sata->wcache && sata->flush)
785 fsl_sata_flush_cache(sata);
790 static void fsl_sata_identify(fsl_sata_t *sata, u16 *id) argument
800 fsl_sata_exec_cmd(sata, cfis, CMD_ATA, 0, (u8 *)id, ATA_ID_WORDS * 2);
807 fsl_sata_t *sata = (fsl_sata_t *)sata_dev_desc[dev].priv; local
813 fsl_sata_t *sata = priv->fsl_sata;
823 if (!sata->link)
833 fsl_sata_identify(sata, id);
850 sata->lba48 = 1;
862 sata_dev_desc[dev].lba48 = sata->lba48;
870 desc->lba48 = sata->lba48;
875 sata->queue_depth = ata_id_queue_depth(id);
878 fsl_sata_xfer_mode(sata, id);
881 fsl_sata_init_wcache(sata, id);
884 fsl_sata_set_features(sata);
995 fsl_sata_t *sata; local
999 sata = priv->fsl_sata;
1001 free(sata->cmd_hdr_tbl_offset);
1002 free(sata->cmd_desc_offset);
1003 free(sata);