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

1 // SPDX-License-Identifier: GPL-2.0+
39 static struct sata_port port[CONFIG_SYS_SATA_MAX_DEVICE]; variable
43 while (words--) { in output_data()
44 __raw_writew (*sect_buf++, (void *)ioaddr->data_addr); in output_data()
50 while (words--) { in input_data()
51 *sect_buf++ = __raw_readw ((void *)ioaddr->data_addr); in input_data()
60 port[num].dev_mask = 1; in sata_bus_softreset()
62 port[num].ctl_reg = 0x08; /*Default value of control reg */ in sata_bus_softreset()
63 writeb (port[num].ctl_reg, port[num].ioaddr.ctl_addr); in sata_bus_softreset()
65 writeb (port[num].ctl_reg | ATA_SRST, port[num].ioaddr.ctl_addr); in sata_bus_softreset()
67 writeb (port[num].ctl_reg, port[num].ioaddr.ctl_addr); in sata_bus_softreset()
78 status = sata_busy_wait (&port[num].ioaddr, ATA_BUSY, 300, 0); in sata_bus_softreset()
81 status = sata_busy_wait (&port[num].ioaddr, ATA_BUSY, 3, 0); in sata_bus_softreset()
90 status = sata_chk_status (&port[num].ioaddr, 0); in sata_bus_softreset()
96 port[num].dev_mask = 0; in sata_bus_softreset()
110 if (!(port[num].dev_mask & 0x01)) { in sata_identify()
111 printf ("dev%d is not present on port#%d\n", dev, num); in sata_identify()
115 debug ("port=%d dev=%d\n", num, dev); in sata_identify()
119 writeb (cmd, port[num].ioaddr.command_addr); in sata_identify()
120 readb (port[num].ioaddr.altstatus_addr); in sata_identify()
123 status = sata_busy_wait (&port[num].ioaddr, ATA_BUSY, 1000, 0); in sata_identify()
126 port[num].dev_mask &= ~0x01; in sata_identify()
130 input_data (&port[num].ioaddr, iobuf, ATA_SECTOR_WORDS); in sata_identify()
146 port[num].dev_mask &= ~0x01; in sata_identify()
156 /* TODO - atm we asume harddisk ie not removable */ in sata_identify()
180 if (!(port[num].dev_mask & 0x01)) { in set_Feature_cmd()
181 debug ("dev%d is not present on port#%d\n", dev, num); in set_Feature_cmd()
185 writeb (SETFEATURES_XFER, port[num].ioaddr.feature_addr); in set_Feature_cmd()
186 writeb (XFER_PIO_4, port[num].ioaddr.nsect_addr); in set_Feature_cmd()
187 writeb (0, port[num].ioaddr.lbal_addr); in set_Feature_cmd()
188 writeb (0, port[num].ioaddr.lbam_addr); in set_Feature_cmd()
189 writeb (0, port[num].ioaddr.lbah_addr); in set_Feature_cmd()
191 writeb (ATA_DEVICE_OBS, port[num].ioaddr.device_addr); in set_Feature_cmd()
192 writeb (ATA_CMD_SET_FEATURES, port[num].ioaddr.command_addr); in set_Feature_cmd()
197 status = sata_busy_wait (&port[num].ioaddr, ATA_BUSY, 5000, 0); in set_Feature_cmd()
200 port[num].dev_mask &= ~0x01; in set_Feature_cmd()
210 if (!(port[num].dev_mask & 0x01)) { in sil3114_spin_down()
225 if (!((status = sata_chk_status (&port[num].ioaddr, 0)) & ATA_DRDY)) { in sil3114_spin_down()
230 writeb (0x00, port[num].ioaddr.feature_addr); in sil3114_spin_down()
232 writeb (0x00, port[num].ioaddr.nsect_addr); in sil3114_spin_down()
233 writeb (0x00, port[num].ioaddr.lbal_addr); in sil3114_spin_down()
234 writeb (0x00, port[num].ioaddr.lbam_addr); in sil3114_spin_down()
235 writeb (0x00, port[num].ioaddr.lbah_addr); in sil3114_spin_down()
237 writeb (ATA_DEVICE_OBS, port[num].ioaddr.device_addr); in sil3114_spin_down()
238 writeb (ATA_CMD_STANDBY, port[num].ioaddr.command_addr); in sil3114_spin_down()
240 status = sata_busy_wait (&port[num].ioaddr, ATA_BUSY, 30000, 0); in sil3114_spin_down()
244 port[num].dev_mask &= ~0x01; in sil3114_spin_down()
256 if (!(port[num].dev_mask & 0x01)) { in sil3114_spin_up()
271 if (!((status = sata_chk_status (&port[num].ioaddr, 0)) & ATA_DRDY)) { in sil3114_spin_up()
278 writeb (0x00, port[num].ioaddr.feature_addr); in sil3114_spin_up()
280 writeb (0x00, port[num].ioaddr.nsect_addr); in sil3114_spin_up()
281 writeb (0x00, port[num].ioaddr.lbal_addr); in sil3114_spin_up()
282 writeb (0x00, port[num].ioaddr.lbam_addr); in sil3114_spin_up()
283 writeb (0x00, port[num].ioaddr.lbah_addr); in sil3114_spin_up()
285 writeb (ATA_DEVICE_OBS, port[num].ioaddr.device_addr); in sil3114_spin_up()
286 writeb (ATA_CMD_IDLE, port[num].ioaddr.command_addr); in sil3114_spin_up()
288 status = sata_busy_wait (&port[num].ioaddr, ATA_BUSY, 30000, 0); in sil3114_spin_up()
292 port[num].dev_mask &= ~0x01; in sil3114_spin_up()
311 * 0x00 - Device stand by
312 * 0x01 - Operation failed
313 * 0x80 - Device idle
314 * 0xff - Device active
320 if (!(port[num].dev_mask & 0x01)) { in check_power_mode()
325 if (!(sata_chk_status (&port[num].ioaddr, 0) & ATA_DRDY)) { in check_power_mode()
330 writeb (0, port[num].ioaddr.feature_addr); in check_power_mode()
331 writeb (0, port[num].ioaddr.nsect_addr); in check_power_mode()
332 writeb (0, port[num].ioaddr.lbal_addr); in check_power_mode()
333 writeb (0, port[num].ioaddr.lbam_addr); in check_power_mode()
334 writeb (0, port[num].ioaddr.lbah_addr); in check_power_mode()
336 writeb (ATA_DEVICE_OBS, port[num].ioaddr.device_addr); in check_power_mode()
337 writeb (ATA_CMD_CHK_POWER, port[num].ioaddr.command_addr); in check_power_mode()
339 status = sata_busy_wait (&port[num].ioaddr, ATA_BUSY, 5000, 0); in check_power_mode()
344 port[num].dev_mask &= ~0x01; in check_power_mode()
347 res = readb (port[num].ioaddr.nsect_addr); in check_power_mode()
355 ioport->data_addr = ioport->cmd_addr + ATA_REG_DATA; in sata_port()
356 ioport->error_addr = ioport->cmd_addr + ATA_REG_ERR; in sata_port()
357 ioport->feature_addr = ioport->cmd_addr + ATA_REG_FEATURE; in sata_port()
358 ioport->nsect_addr = ioport->cmd_addr + ATA_REG_NSECT; in sata_port()
359 ioport->lbal_addr = ioport->cmd_addr + ATA_REG_LBAL; in sata_port()
360 ioport->lbam_addr = ioport->cmd_addr + ATA_REG_LBAM; in sata_port()
361 ioport->lbah_addr = ioport->cmd_addr + ATA_REG_LBAH; in sata_port()
362 ioport->device_addr = ioport->cmd_addr + ATA_REG_DEVICE; in sata_port()
363 ioport->status_addr = ioport->cmd_addr + ATA_REG_STATUS; in sata_port()
364 ioport->command_addr = ioport->cmd_addr + ATA_REG_CMD; in sata_port()
370 u32 port = iobase[5]; in wait_for_irq() local
373 port += VND_TF_CNST_CH0; in wait_for_irq()
376 port += VND_TF_CNST_CH1; in wait_for_irq()
379 port += VND_TF_CNST_CH2; in wait_for_irq()
382 port += VND_TF_CNST_CH3; in wait_for_irq()
389 if (readl (port) & VND_TF_CNST_INTST) { in wait_for_irq()
393 max--; in wait_for_irq()
409 max--; in sata_busy_wait()
418 return readb (ioaddr->status_addr); in sata_chk_status()
420 return readb (ioaddr->altstatus_addr); in sata_chk_status()
444 if (!(sata_chk_status (&port[device].ioaddr, 0) & ATA_DRDY)) { in do_one_read()
453 writeb (0, port[device].ioaddr.nsect_addr); in do_one_read()
454 writeb ((blknr >> 24) & 0xFF, port[device].ioaddr.lbal_addr); in do_one_read()
455 writeb ((blknr >> 32) & 0xFF, port[device].ioaddr.lbam_addr); in do_one_read()
456 writeb ((blknr >> 40) & 0xFF, port[device].ioaddr.lbah_addr); in do_one_read()
459 writeb (blkcnt, port[device].ioaddr.nsect_addr); in do_one_read()
460 writeb (((blknr) >> 0) & 0xFF, port[device].ioaddr.lbal_addr); in do_one_read()
461 writeb ((blknr >> 8) & 0xFF, port[device].ioaddr.lbam_addr); in do_one_read()
462 writeb ((blknr >> 16) & 0xFF, port[device].ioaddr.lbah_addr); in do_one_read()
466 writeb (ATA_LBA, port[device].ioaddr.device_addr); in do_one_read()
467 writeb (ATA_CMD_PIO_READ_EXT, port[device].ioaddr.command_addr); in do_one_read()
472 port[device].ioaddr.device_addr); in do_one_read()
473 writeb (ATA_CMD_PIO_READ, port[device].ioaddr.command_addr); in do_one_read()
476 status = sata_busy_wait (&port[device].ioaddr, ATA_BUSY, 10000, 1); in do_one_read()
482 err = readb (port[device].ioaddr.error_addr); in do_one_read()
487 while (blkcnt--) { in do_one_read()
494 status = sata_chk_status (&port[device].ioaddr, 0); in do_one_read()
497 readb (port[device].ioaddr.error_addr)); in do_one_read()
501 input_data (&port[device].ioaddr, buff, ATA_SECTOR_WORDS); in do_one_read()
520 printf ("Drive doesn't support 48-bit addressing\n"); in sata_read()
542 blkcnt -= sread; in sata_read()
561 printf ("Drive doesn't support 48-bit addressing\n"); in sata_write()
568 /*Port Number */ in sata_write()
571 while (blkcnt-- > 0) { in sata_write()
572 status = sata_busy_wait (&port[num].ioaddr, ATA_BUSY, 500, 0); in sata_write()
574 printf ("ata%u failed to respond\n", port[num].port_no); in sata_write()
580 writeb (0, port[num].ioaddr.nsect_addr); in sata_write()
582 port[num].ioaddr.lbal_addr); in sata_write()
584 port[num].ioaddr.lbam_addr); in sata_write()
586 port[num].ioaddr.lbah_addr); in sata_write()
589 writeb (1, port[num].ioaddr.nsect_addr); in sata_write()
590 writeb ((blknr >> 0) & 0xFF, port[num].ioaddr.lbal_addr); in sata_write()
591 writeb ((blknr >> 8) & 0xFF, port[num].ioaddr.lbam_addr); in sata_write()
592 writeb ((blknr >> 16) & 0xFF, port[num].ioaddr.lbah_addr); in sata_write()
595 writeb (ATA_LBA, port[num].ioaddr.device_addr); in sata_write()
596 writeb (ATA_CMD_PIO_WRITE_EXT, port[num].ioaddr.command_addr); in sata_write()
601 port[num].ioaddr.device_addr); in sata_write()
602 writeb (ATA_CMD_PIO_WRITE, port[num].ioaddr.command_addr); in sata_write()
607 status = sata_busy_wait (&port[num].ioaddr, ATA_BUSY, 4000, 0); in sata_write()
614 output_data (&port[num].ioaddr, buffer, ATA_SECTOR_WORDS); in sata_write()
615 readb (port[num].ioaddr.altstatus_addr); in sata_write()
648 if ((devno = pci_find_device (SIL_VEND_ID, SIL3114_DEVICE_ID, 0)) == -1) { in init_sata()
709 /* Check if device is connected to port */
712 u32 port = iobase[5]; in sata_bus_probe() local
716 port += VND_SSTATUS_CH0; in sata_bus_probe()
719 port += VND_SSTATUS_CH1; in sata_bus_probe()
722 port += VND_SSTATUS_CH2; in sata_bus_probe()
725 port += VND_SSTATUS_CH3; in sata_bus_probe()
730 val = readl (port); in sata_bus_probe()
740 u32 port = iobase[5]; in sata_phy_reset() local
744 port += VND_SCONTROL_CH0; in sata_phy_reset()
747 port += VND_SCONTROL_CH1; in sata_phy_reset()
750 port += VND_SCONTROL_CH2; in sata_phy_reset()
753 port += VND_SCONTROL_CH3; in sata_phy_reset()
758 val = readl (port); in sata_phy_reset()
759 writel (val | SATA_SC_DET_RST, port); in sata_phy_reset()
761 writel (val & ~SATA_SC_DET_RST, port); in sata_phy_reset()
770 port[0].port_no = 0; in scan_sata()
771 port[0].ioaddr.cmd_addr = iobase[5] + VND_TF0_CH0; in scan_sata()
772 port[0].ioaddr.altstatus_addr = port[0].ioaddr.ctl_addr = in scan_sata()
774 port[0].ioaddr.bmdma_addr = iobase[5] + VND_BMDMA_CH0; in scan_sata()
778 port[1].port_no = 0; in scan_sata()
779 port[1].ioaddr.cmd_addr = iobase[5] + VND_TF0_CH1; in scan_sata()
780 port[1].ioaddr.altstatus_addr = port[1].ioaddr.ctl_addr = in scan_sata()
782 port[1].ioaddr.bmdma_addr = iobase[5] + VND_BMDMA_CH1; in scan_sata()
786 port[2].port_no = 0; in scan_sata()
787 port[2].ioaddr.cmd_addr = iobase[5] + VND_TF0_CH2; in scan_sata()
788 port[2].ioaddr.altstatus_addr = port[2].ioaddr.ctl_addr = in scan_sata()
790 port[2].ioaddr.bmdma_addr = iobase[5] + VND_BMDMA_CH2; in scan_sata()
794 port[3].port_no = 0; in scan_sata()
795 port[3].ioaddr.cmd_addr = iobase[5] + VND_TF0_CH3; in scan_sata()
796 port[3].ioaddr.altstatus_addr = port[3].ioaddr.ctl_addr = in scan_sata()
798 port[3].ioaddr.bmdma_addr = iobase[5] + VND_BMDMA_CH3; in scan_sata()
802 printf ("Tried to scan unknown port: ata%d\n", dev); in scan_sata()
807 sata_port (&port[dev].ioaddr); in scan_sata()
811 port[dev].port_state = 0; in scan_sata()
812 debug ("SATA#%d port is not present\n", dev); in scan_sata()
814 debug ("SATA#%d port is present\n", dev); in scan_sata()
819 port[dev].port_state = 0; in scan_sata()
821 port[dev].port_state = 1; in scan_sata()
824 port[dev].port_state = 1; in scan_sata()
827 if (port[dev].port_state == 1) { in scan_sata()