Lines Matching refs:sata
136 static void sil_read_fis(struct sil_sata *sata, int tag, in sil_read_fis() argument
139 void *port = sata->port; in sil_read_fis()
151 static int sil_exec_cmd(struct sil_sata *sata, struct sil_cmd_block *pcmd, in sil_exec_cmd() argument
154 void *port = sata->port; in sil_exec_cmd()
155 u64 paddr = virt_to_bus(sata->devno, pcmd); in sil_exec_cmd()
187 static int sil_cmd_set_feature(struct sil_sata *sata) in sil_cmd_set_feature() argument
201 udma_cap = (u8)(sata->udma & 0xff); in sil_cmd_set_feature()
213 ret = sil_exec_cmd(sata, pcmd, 0); in sil_cmd_set_feature()
215 sil_read_fis(sata, 0, &fis); in sil_cmd_set_feature()
217 readl(sata->port + PORT_SERROR)); in sil_cmd_set_feature()
225 static void sil_sata_init_wcache(struct sil_sata *sata, u16 *id) in sil_sata_init_wcache() argument
228 sata->wcache = 1; in sil_sata_init_wcache()
230 sata->flush = 1; in sil_sata_init_wcache()
232 sata->flush_ext = 1; in sil_sata_init_wcache()
235 static void sil_sata_set_feature_by_id(struct sil_sata *sata, u16 *id) in sil_sata_set_feature_by_id() argument
240 sata->lba48 = 1; in sil_sata_set_feature_by_id()
247 sil_sata_init_wcache(sata, id); in sil_sata_set_feature_by_id()
248 sil_cmd_set_feature(sata); in sil_sata_set_feature_by_id()
251 static int sil_cmd_identify_device(struct sil_sata *sata, u16 *id) in sil_cmd_identify_device() argument
263 pcmd->sge.addr = cpu_to_le64(virt_to_bus(sata->devno, id)); in sil_cmd_identify_device()
267 ret = sil_exec_cmd(sata, pcmd, 0); in sil_cmd_identify_device()
269 sil_read_fis(sata, 0, &fis); in sil_cmd_identify_device()
270 printf("Err: id cmd(0x%x).\n", readl(sata->port + PORT_SERROR)); in sil_cmd_identify_device()
279 static int sil_cmd_soft_reset(struct sil_sata *sata) in sil_cmd_soft_reset() argument
283 void *port = sata->port; in sil_cmd_soft_reset()
288 printf("SRST: port %d not ready\n", sata->id); in sil_cmd_soft_reset()
298 ret = sil_exec_cmd(sata, &cmdb, 0); in sil_cmd_soft_reset()
300 sil_read_fis(sata, 0, &fis); in sil_cmd_soft_reset()
309 static ulong sil_sata_rw_cmd(struct sil_sata *sata, ulong start, ulong blkcnt, in sil_sata_rw_cmd() argument
337 pcmd->sge.addr = cpu_to_le64(virt_to_bus(sata->devno, buffer)); in sil_sata_rw_cmd()
341 ret = sil_exec_cmd(sata, pcmd, 0); in sil_sata_rw_cmd()
343 sil_read_fis(sata, 0, &fis); in sil_sata_rw_cmd()
345 readl(sata->port + PORT_SERROR)); in sil_sata_rw_cmd()
353 static ulong sil_sata_rw_cmd_ext(struct sil_sata *sata, ulong start, in sil_sata_rw_cmd_ext() argument
384 pcmd->sge.addr = cpu_to_le64(virt_to_bus(sata->devno, buffer)); in sil_sata_rw_cmd_ext()
388 ret = sil_exec_cmd(sata, pcmd, 0); in sil_sata_rw_cmd_ext()
390 sil_read_fis(sata, 0, &fis); in sil_sata_rw_cmd_ext()
392 readl(sata->port + PORT_SERROR)); in sil_sata_rw_cmd_ext()
400 static ulong sil_sata_rw_lba28(struct sil_sata *sata, ulong blknr, in sil_sata_rw_lba28() argument
414 sil_sata_rw_cmd(sata, start, max_blks, addr, is_write); in sil_sata_rw_lba28()
419 sil_sata_rw_cmd(sata, start, blks, addr, is_write); in sil_sata_rw_lba28()
429 static ulong sil_sata_rw_lba48(struct sil_sata *sata, ulong blknr, in sil_sata_rw_lba48() argument
443 sil_sata_rw_cmd_ext(sata, start, max_blks, in sil_sata_rw_lba48()
449 sil_sata_rw_cmd_ext(sata, start, blks, in sil_sata_rw_lba48()
460 static void sil_sata_cmd_flush_cache(struct sil_sata *sata) in sil_sata_cmd_flush_cache() argument
469 sil_exec_cmd(sata, pcmd, 0); in sil_sata_cmd_flush_cache()
472 static void sil_sata_cmd_flush_cache_ext(struct sil_sata *sata) in sil_sata_cmd_flush_cache_ext() argument
481 sil_exec_cmd(sata, pcmd, 0); in sil_sata_cmd_flush_cache_ext()
490 struct sil_sata *sata = (struct sil_sata *)sata_dev_desc[dev].priv; local
497 struct sil_sata *sata = priv->sil_sata_desc[port_number];
501 if (sata->lba48)
502 rc = sil_sata_rw_lba48(sata, blknr, blkcnt, buffer, READ_CMD);
504 rc = sil_sata_rw_lba28(sata, blknr, blkcnt, buffer, READ_CMD);
515 struct sil_sata *sata = (struct sil_sata *)sata_dev_desc[dev].priv; local
522 struct sil_sata *sata = priv->sil_sata_desc[port_number];
526 if (sata->lba48) {
527 rc = sil_sata_rw_lba48(sata, blknr, blkcnt, buffer, WRITE_CMD);
528 if (sata->wcache && sata->flush_ext)
529 sil_sata_cmd_flush_cache_ext(sata);
531 rc = sil_sata_rw_lba28(sata, blknr, blkcnt, buffer, WRITE_CMD);
532 if (sata->wcache && sata->flush)
533 sil_sata_cmd_flush_cache(sata);
547 struct sil_sata *sata; local
605 sata = (struct sil_sata *)malloc(sizeof(struct sil_sata));
606 if (!sata) {
610 memset((void *)sata, 0, sizeof(struct sil_sata));
614 sata_dev_desc[dev].priv = (void *)sata;
615 sata->devno = sata_info.devno;
617 priv->sil_sata_desc[dev] = sata;
620 sata->devno = uc_dev->parent;
622 sata->devno = sata_info.devno;
625 sata->id = dev;
626 sata->port = port;
627 sprintf(sata->name, "SATA#%d", dev);
628 sil_cmd_soft_reset(sata);
707 struct sil_sata *sata = (struct sil_sata *)sata_dev_desc[dev].priv; local
713 struct sil_sata *sata = priv->sil_sata_desc[dev];
725 sil_cmd_identify_device(sata, id);
727 sil_sata_set_feature_by_id(sata, id);
745 sata_dev_desc[dev].lba48 = sata->lba48;
753 desc->lba48 = sata->lba48;
886 struct sil_sata *sata; local
892 sata = priv->sil_sata_desc[i];
893 if (sata)
894 free(sata);