Lines Matching +full:sata +full:- +full:port

5  * SPDX-License-Identifier:	GPL-2.0+
15 #include <sata.h>
17 #include <sata.h>
36 printf("fis_type: %02x\n", s->fis_type); in sil_sata_dump_fis()
37 printf("pm_port_i: %02x\n", s->pm_port_i); in sil_sata_dump_fis()
38 printf("status: %02x\n", s->status); in sil_sata_dump_fis()
39 printf("error: %02x\n", s->error); in sil_sata_dump_fis()
40 printf("lba_low: %02x\n", s->lba_low); in sil_sata_dump_fis()
41 printf("lba_mid: %02x\n", s->lba_mid); in sil_sata_dump_fis()
42 printf("lba_high: %02x\n", s->lba_high); in sil_sata_dump_fis()
43 printf("device: %02x\n", s->device); in sil_sata_dump_fis()
44 printf("lba_low_exp: %02x\n", s->lba_low_exp); in sil_sata_dump_fis()
45 printf("lba_mid_exp: %02x\n", s->lba_mid_exp); in sil_sata_dump_fis()
46 printf("lba_high_exp: %02x\n", s->lba_high_exp); in sil_sata_dump_fis()
47 printf("res1: %02x\n", s->res1); in sil_sata_dump_fis()
48 printf("sector_count: %02x\n", s->sector_count); in sil_sata_dump_fis()
49 printf("sector_count_exp: %02x\n", s->sector_count_exp); in sil_sata_dump_fis()
60 if ((speed - 1) > 2) in sata_spd_string()
63 return spd_str[speed - 1]; in sata_spd_string()
74 timeout_msec--; in ata_wait_register()
81 static void sil_config_port(void *port) in sil_config_port() argument
84 writel(PORT_CS_IRQ_WOC, port + PORT_CTRL_CLR); in sil_config_port()
87 writew(0x8000, port + PORT_DECODE_ERR_THRESH); in sil_config_port()
88 writew(0x8000, port + PORT_CRC_ERR_THRESH); in sil_config_port()
89 writew(0x8000, port + PORT_HSHK_ERR_THRESH); in sil_config_port()
90 writew(0x0000, port + PORT_DECODE_ERR_CNT); in sil_config_port()
91 writew(0x0000, port + PORT_CRC_ERR_CNT); in sil_config_port()
92 writew(0x0000, port + PORT_HSHK_ERR_CNT); in sil_config_port()
95 writel(PORT_CS_32BIT_ACTV, port + PORT_CTRL_CLR); in sil_config_port()
97 /* clear port multiplier enable and resume bits */ in sil_config_port()
98 writel(PORT_CS_PMP_EN | PORT_CS_PMP_RESUME, port + PORT_CTRL_CLR); in sil_config_port()
101 static int sil_init_port(void *port) in sil_init_port() argument
105 writel(PORT_CS_INIT, port + PORT_CTRL_STAT); in sil_init_port()
106 ata_wait_register(port + PORT_CTRL_STAT, in sil_init_port()
108 tmp = ata_wait_register(port + PORT_CTRL_STAT, in sil_init_port()
119 struct sil_sata *sata = sata_dev_desc[dev].priv; in sil_read_fis() local
120 void *port = sata->port; in sil_read_fis() local
125 prb = port + PORT_LRAM + tag * PORT_LRAM_SLOT_SZ; in sil_read_fis()
126 src = (u32 *)&prb->fis; in sil_read_fis()
134 struct sil_sata *sata = sata_dev_desc[dev].priv; in sil_exec_cmd() local
135 void *port = sata->port; in sil_exec_cmd() local
136 u64 paddr = virt_to_bus(sata->devno, pcmd); in sil_exec_cmd()
140 writel(PORT_IRQ_COMPLETE | PORT_IRQ_ERROR, port + PORT_IRQ_ENABLE_CLR); in sil_exec_cmd()
143 writel((u32)paddr, port + PORT_CMD_ACTIVATE + tag * 8); in sil_exec_cmd()
144 writel((u64)paddr >> 32, port + PORT_CMD_ACTIVATE + tag * 8 + 4); in sil_exec_cmd()
147 irq_stat = ata_wait_register(port + PORT_IRQ_STAT, irq_mask, in sil_exec_cmd()
151 writel(irq_mask, port + PORT_IRQ_STAT); in sil_exec_cmd()
157 /* force port into known state */ in sil_exec_cmd()
158 sil_init_port(port); in sil_exec_cmd()
170 struct sil_sata *sata = sata_dev_desc[dev].priv; in sil_cmd_set_feature() local
177 pcmd->prb.fis.fis_type = SATA_FIS_TYPE_REGISTER_H2D; in sil_cmd_set_feature()
178 pcmd->prb.fis.pm_port_c = (1 << 7); in sil_cmd_set_feature()
179 pcmd->prb.fis.command = ATA_CMD_SET_FEATURES; in sil_cmd_set_feature()
180 pcmd->prb.fis.features = SETFEATURES_XFER; in sil_cmd_set_feature()
183 udma_cap = (u8)(sata->udma & 0xff); in sil_cmd_set_feature()
187 pcmd->prb.fis.sector_count = XFER_UDMA_6; in sil_cmd_set_feature()
189 pcmd->prb.fis.sector_count = XFER_UDMA_5; in sil_cmd_set_feature()
191 pcmd->prb.fis.sector_count = XFER_UDMA_4; in sil_cmd_set_feature()
193 pcmd->prb.fis.sector_count = XFER_UDMA_3; in sil_cmd_set_feature()
199 readl(sata->port + PORT_SERROR)); in sil_cmd_set_feature()
209 struct sil_sata *sata = sata_dev_desc[dev].priv; in sil_cmd_identify_device() local
215 pcmd->prb.ctrl = cpu_to_le16(PRB_CTRL_PROTOCOL); in sil_cmd_identify_device()
216 pcmd->prb.prot = cpu_to_le16(PRB_PROT_READ); in sil_cmd_identify_device()
217 pcmd->prb.fis.fis_type = SATA_FIS_TYPE_REGISTER_H2D; in sil_cmd_identify_device()
218 pcmd->prb.fis.pm_port_c = (1 << 7); in sil_cmd_identify_device()
219 pcmd->prb.fis.command = ATA_CMD_ID_ATA; in sil_cmd_identify_device()
220 pcmd->sge.addr = cpu_to_le64(virt_to_bus(sata->devno, id)); in sil_cmd_identify_device()
221 pcmd->sge.cnt = cpu_to_le32(sizeof(id[0]) * ATA_ID_WORDS); in sil_cmd_identify_device()
222 pcmd->sge.flags = cpu_to_le32(SGE_TRM); in sil_cmd_identify_device()
227 printf("Err: id cmd(0x%x).\n", readl(sata->port + PORT_SERROR)); in sil_cmd_identify_device()
239 struct sil_sata *sata = sata_dev_desc[dev].priv; in sil_cmd_soft_reset() local
241 void *port = sata->port; in sil_cmd_soft_reset() local
244 /* put the port into known state */ in sil_cmd_soft_reset()
245 if (sil_init_port(port)) { in sil_cmd_soft_reset()
246 printf("SRST: port %d not ready\n", dev); in sil_cmd_soft_reset()
252 pcmd->prb.ctrl = cpu_to_le16(PRB_CTRL_SRST); in sil_cmd_soft_reset()
253 pcmd->prb.fis.fis_type = SATA_FIS_TYPE_REGISTER_H2D; in sil_cmd_soft_reset()
254 pcmd->prb.fis.pm_port_c = 0xf; in sil_cmd_soft_reset()
270 struct sil_sata *sata = sata_dev_desc[dev].priv; in sil_sata_rw_cmd() local
278 pcmd->prb.ctrl = cpu_to_le16(PRB_CTRL_PROTOCOL); in sil_sata_rw_cmd()
279 pcmd->prb.fis.fis_type = SATA_FIS_TYPE_REGISTER_H2D; in sil_sata_rw_cmd()
280 pcmd->prb.fis.pm_port_c = (1 << 7); in sil_sata_rw_cmd()
282 pcmd->prb.fis.command = ATA_CMD_WRITE; in sil_sata_rw_cmd()
283 pcmd->prb.prot = cpu_to_le16(PRB_PROT_WRITE); in sil_sata_rw_cmd()
285 pcmd->prb.fis.command = ATA_CMD_READ; in sil_sata_rw_cmd()
286 pcmd->prb.prot = cpu_to_le16(PRB_PROT_READ); in sil_sata_rw_cmd()
289 pcmd->prb.fis.device = ATA_LBA; in sil_sata_rw_cmd()
290 pcmd->prb.fis.device |= (block >> 24) & 0xf; in sil_sata_rw_cmd()
291 pcmd->prb.fis.lba_high = (block >> 16) & 0xff; in sil_sata_rw_cmd()
292 pcmd->prb.fis.lba_mid = (block >> 8) & 0xff; in sil_sata_rw_cmd()
293 pcmd->prb.fis.lba_low = block & 0xff; in sil_sata_rw_cmd()
294 pcmd->prb.fis.sector_count = (u8)blkcnt & 0xff; in sil_sata_rw_cmd()
296 pcmd->sge.addr = cpu_to_le64(virt_to_bus(sata->devno, buffer)); in sil_sata_rw_cmd()
297 pcmd->sge.cnt = cpu_to_le32(blkcnt * ATA_SECT_SIZE); in sil_sata_rw_cmd()
298 pcmd->sge.flags = cpu_to_le32(SGE_TRM); in sil_sata_rw_cmd()
304 readl(sata->port + PORT_SERROR)); in sil_sata_rw_cmd()
315 struct sil_sata *sata = sata_dev_desc[dev].priv; in sil_sata_rw_cmd_ext() local
323 pcmd->prb.ctrl = cpu_to_le16(PRB_CTRL_PROTOCOL); in sil_sata_rw_cmd_ext()
324 pcmd->prb.fis.fis_type = SATA_FIS_TYPE_REGISTER_H2D; in sil_sata_rw_cmd_ext()
325 pcmd->prb.fis.pm_port_c = (1 << 7); in sil_sata_rw_cmd_ext()
327 pcmd->prb.fis.command = ATA_CMD_WRITE_EXT; in sil_sata_rw_cmd_ext()
328 pcmd->prb.prot = cpu_to_le16(PRB_PROT_WRITE); in sil_sata_rw_cmd_ext()
330 pcmd->prb.fis.command = ATA_CMD_READ_EXT; in sil_sata_rw_cmd_ext()
331 pcmd->prb.prot = cpu_to_le16(PRB_PROT_READ); in sil_sata_rw_cmd_ext()
334 pcmd->prb.fis.lba_high_exp = (block >> 40) & 0xff; in sil_sata_rw_cmd_ext()
335 pcmd->prb.fis.lba_mid_exp = (block >> 32) & 0xff; in sil_sata_rw_cmd_ext()
336 pcmd->prb.fis.lba_low_exp = (block >> 24) & 0xff; in sil_sata_rw_cmd_ext()
337 pcmd->prb.fis.lba_high = (block >> 16) & 0xff; in sil_sata_rw_cmd_ext()
338 pcmd->prb.fis.lba_mid = (block >> 8) & 0xff; in sil_sata_rw_cmd_ext()
339 pcmd->prb.fis.lba_low = block & 0xff; in sil_sata_rw_cmd_ext()
340 pcmd->prb.fis.device = ATA_LBA; in sil_sata_rw_cmd_ext()
341 pcmd->prb.fis.sector_count_exp = (blkcnt >> 8) & 0xff; in sil_sata_rw_cmd_ext()
342 pcmd->prb.fis.sector_count = blkcnt & 0xff; in sil_sata_rw_cmd_ext()
344 pcmd->sge.addr = cpu_to_le64(virt_to_bus(sata->devno, buffer)); in sil_sata_rw_cmd_ext()
345 pcmd->sge.cnt = cpu_to_le32(blkcnt * ATA_SECT_SIZE); in sil_sata_rw_cmd_ext()
346 pcmd->sge.flags = cpu_to_le32(SGE_TRM); in sil_sata_rw_cmd_ext()
352 readl(sata->port + PORT_SERROR)); in sil_sata_rw_cmd_ext()
375 blks -= max_blks; in sil_sata_rw_lba28()
404 blks -= max_blks; in sil_sata_rw_lba48()
423 pcmd->prb.fis.fis_type = SATA_FIS_TYPE_REGISTER_H2D; in sil_sata_cmd_flush_cache()
424 pcmd->prb.fis.pm_port_c = (1 << 7); in sil_sata_cmd_flush_cache()
425 pcmd->prb.fis.command = ATA_CMD_FLUSH; in sil_sata_cmd_flush_cache()
435 pcmd->prb.fis.fis_type = SATA_FIS_TYPE_REGISTER_H2D; in sil_sata_cmd_flush_cache_ext()
436 pcmd->prb.fis.pm_port_c = (1 << 7); in sil_sata_cmd_flush_cache_ext()
437 pcmd->prb.fis.command = ATA_CMD_FLUSH_EXT; in sil_sata_cmd_flush_cache_ext()
444 struct sil_sata *sata = sata_dev_desc[dev].priv; in sil_sata_init_wcache() local
447 sata->wcache = 1; in sil_sata_init_wcache()
449 sata->flush = 1; in sil_sata_init_wcache()
451 sata->flush_ext = 1; in sil_sata_init_wcache()
456 struct sil_sata *sata = sata_dev_desc[dev].priv; in sil_sata_get_wcache() local
458 return sata->wcache; in sil_sata_get_wcache()
463 struct sil_sata *sata = sata_dev_desc[dev].priv; in sil_sata_get_flush() local
465 return sata->flush; in sil_sata_get_flush()
470 struct sil_sata *sata = sata_dev_desc[dev].priv; in sil_sata_get_flush_ext() local
472 return sata->flush_ext; in sil_sata_get_flush_ext()
476 * SATA interface between low level driver and command layer
480 struct sil_sata *sata = sata_dev_desc[dev].priv; in sata_read() local
483 if (sata->lba48) in sata_read()
492 * SATA interface between low level driver and command layer
496 struct sil_sata *sata = sata_dev_desc[dev].priv; in sata_write() local
499 if (sata->lba48) { in sata_write()
513 * SATA interface between low level driver and command layer
528 if (devno == -1) in init_sata()
533 /* get the port count */ in init_sata()
580 * SATA interface between low level driver and command layer
587 struct sil_sata *sata; in scan_sata() local
588 void *port; in scan_sata() local
594 printf("SATA#%d is not present\n", dev); in scan_sata()
598 printf("SATA#%d\n", dev); in scan_sata()
599 port = (void *)sata_info.iobase[1] + in scan_sata()
600 PORT_REGS_SIZE * (dev - sata_info.portbase); in scan_sata()
603 writel(0x20c, port + PORT_PHY_CFG); in scan_sata()
605 /* clear port RST */ in scan_sata()
606 tmp = readl(port + PORT_CTRL_STAT); in scan_sata()
608 writel(PORT_CS_PORT_RST, port + PORT_CTRL_CLR); in scan_sata()
609 tmp = ata_wait_register(port + PORT_CTRL_STAT, in scan_sata()
612 printf("Err: Failed to clear port RST\n"); in scan_sata()
617 tmp = readl(port + PORT_SSTATUS); in scan_sata()
623 tmp = readl(port + PORT_SSTATUS); in scan_sata()
629 /* Wait for port ready */ in scan_sata()
630 tmp = ata_wait_register(port + PORT_CTRL_STAT, in scan_sata()
633 printf("%d port not ready.\n", dev); in scan_sata()
637 /* configure port */ in scan_sata()
638 sil_config_port(port); in scan_sata()
640 /* Reset port */ in scan_sata()
641 writel(PORT_CS_DEV_RST, port + PORT_CTRL_STAT); in scan_sata()
642 readl(port + PORT_CTRL_STAT); in scan_sata()
643 tmp = ata_wait_register(port + PORT_CTRL_STAT, PORT_CS_DEV_RST, in scan_sata()
646 printf("%d port reset failed.\n", dev); in scan_sata()
650 sata = (struct sil_sata *)malloc(sizeof(struct sil_sata)); in scan_sata()
651 if (!sata) { in scan_sata()
655 memset((void *)sata, 0, sizeof(struct sil_sata)); in scan_sata()
657 /* turn on port interrupt */ in scan_sata()
659 tmp |= (1 << (dev - sata_info.portbase)); in scan_sata()
663 sata_dev_desc[dev].priv = (void *)sata; in scan_sata()
664 sata->port = port; in scan_sata()
665 sata->devno = sata_info.devno; in scan_sata()
666 sprintf(sata->name, "SATA#%d", dev); in scan_sata()
668 tmp = readl(port + PORT_SSTATUS); in scan_sata()
675 free((void *)sata); in scan_sata()
684 sata->lba48 = 1; in scan_sata()