Lines Matching refs:num

29 u8 sil3114_spin_up (int num);
30 u8 sil3114_spin_down (int num);
31 static int sata_bus_softreset (int num);
32 static void sata_identify (int num, int dev);
33 static u8 check_power_mode (int num);
35 static void set_Feature_cmd (int num, int dev);
60 static int sata_bus_softreset (int num) in sata_bus_softreset() argument
64 port[num].dev_mask = 1; in sata_bus_softreset()
66 port[num].ctl_reg = 0x08; /*Default value of control reg */ in sata_bus_softreset()
67 writeb (port[num].ctl_reg, port[num].ioaddr.ctl_addr); in sata_bus_softreset()
69 writeb (port[num].ctl_reg | ATA_SRST, port[num].ioaddr.ctl_addr); in sata_bus_softreset()
71 writeb (port[num].ctl_reg, port[num].ioaddr.ctl_addr); in sata_bus_softreset()
82 status = sata_busy_wait (&port[num].ioaddr, ATA_BUSY, 300, 0); in sata_bus_softreset()
85 status = sata_busy_wait (&port[num].ioaddr, ATA_BUSY, 3, 0); in sata_bus_softreset()
89 printf ("ata%u is slow to respond,plz be patient\n", num); in sata_bus_softreset()
94 status = sata_chk_status (&port[num].ioaddr, 0); in sata_bus_softreset()
98 printf ("ata%u failed to respond : ", num); in sata_bus_softreset()
100 port[num].dev_mask = 0; in sata_bus_softreset()
106 static void sata_identify (int num, int dev) in sata_identify() argument
108 u8 cmd = 0, status = 0, devno = num; in sata_identify()
114 if (!(port[num].dev_mask & 0x01)) { in sata_identify()
115 printf ("dev%d is not present on port#%d\n", dev, num); in sata_identify()
119 debug ("port=%d dev=%d\n", num, dev); in sata_identify()
123 writeb (cmd, port[num].ioaddr.command_addr); in sata_identify()
124 readb (port[num].ioaddr.altstatus_addr); in sata_identify()
127 status = sata_busy_wait (&port[num].ioaddr, ATA_BUSY, 1000, 0); in sata_identify()
130 port[num].dev_mask &= ~0x01; in sata_identify()
134 input_data (&port[num].ioaddr, iobuf, ATA_SECTOR_WORDS); in sata_identify()
142 debug ("ata%u: no dma/lba\n", num); in sata_identify()
150 port[num].dev_mask &= ~0x01; in sata_identify()
180 static void set_Feature_cmd (int num, int dev) in set_Feature_cmd() argument
184 if (!(port[num].dev_mask & 0x01)) { in set_Feature_cmd()
185 debug ("dev%d is not present on port#%d\n", dev, num); in set_Feature_cmd()
189 writeb (SETFEATURES_XFER, port[num].ioaddr.feature_addr); in set_Feature_cmd()
190 writeb (XFER_PIO_4, port[num].ioaddr.nsect_addr); in set_Feature_cmd()
191 writeb (0, port[num].ioaddr.lbal_addr); in set_Feature_cmd()
192 writeb (0, port[num].ioaddr.lbam_addr); in set_Feature_cmd()
193 writeb (0, port[num].ioaddr.lbah_addr); in set_Feature_cmd()
195 writeb (ATA_DEVICE_OBS, port[num].ioaddr.device_addr); in set_Feature_cmd()
196 writeb (ATA_CMD_SET_FEATURES, port[num].ioaddr.command_addr); in set_Feature_cmd()
201 status = sata_busy_wait (&port[num].ioaddr, ATA_BUSY, 5000, 0); in set_Feature_cmd()
204 port[num].dev_mask &= ~0x01; in set_Feature_cmd()
208 u8 sil3114_spin_down (int num) in sil3114_spin_down() argument
214 if (!(port[num].dev_mask & 0x01)) { in sil3114_spin_down()
215 debug ("Device ata%d is not present\n", num); in sil3114_spin_down()
219 if ((status = check_power_mode (num)) == 0x00) { in sil3114_spin_down()
225 printf ("Failed to check power mode on ata%d\n", num); in sil3114_spin_down()
229 if (!((status = sata_chk_status (&port[num].ioaddr, 0)) & ATA_DRDY)) { in sil3114_spin_down()
230 printf ("Device ata%d not ready\n", num); in sil3114_spin_down()
234 writeb (0x00, port[num].ioaddr.feature_addr); in sil3114_spin_down()
236 writeb (0x00, port[num].ioaddr.nsect_addr); in sil3114_spin_down()
237 writeb (0x00, port[num].ioaddr.lbal_addr); in sil3114_spin_down()
238 writeb (0x00, port[num].ioaddr.lbam_addr); in sil3114_spin_down()
239 writeb (0x00, port[num].ioaddr.lbah_addr); in sil3114_spin_down()
241 writeb (ATA_DEVICE_OBS, port[num].ioaddr.device_addr); in sil3114_spin_down()
242 writeb (ATA_CMD_STANDBY, port[num].ioaddr.command_addr); in sil3114_spin_down()
244 status = sata_busy_wait (&port[num].ioaddr, ATA_BUSY, 30000, 0); in sil3114_spin_down()
248 port[num].dev_mask &= ~0x01; in sil3114_spin_down()
254 u8 sil3114_spin_up (int num) in sil3114_spin_up() argument
260 if (!(port[num].dev_mask & 0x01)) { in sil3114_spin_up()
261 debug ("Device ata%d is not present\n", num); in sil3114_spin_up()
265 if ((status = check_power_mode (num)) != 0x00) { in sil3114_spin_up()
267 printf ("Failed to check power mode on ata%d\n", num); in sil3114_spin_up()
275 if (!((status = sata_chk_status (&port[num].ioaddr, 0)) & ATA_DRDY)) { in sil3114_spin_up()
276 printf ("Device ata%d not ready\n", num); in sil3114_spin_up()
282 writeb (0x00, port[num].ioaddr.feature_addr); in sil3114_spin_up()
284 writeb (0x00, port[num].ioaddr.nsect_addr); in sil3114_spin_up()
285 writeb (0x00, port[num].ioaddr.lbal_addr); in sil3114_spin_up()
286 writeb (0x00, port[num].ioaddr.lbam_addr); in sil3114_spin_up()
287 writeb (0x00, port[num].ioaddr.lbah_addr); in sil3114_spin_up()
289 writeb (ATA_DEVICE_OBS, port[num].ioaddr.device_addr); in sil3114_spin_up()
290 writeb (ATA_CMD_IDLE, port[num].ioaddr.command_addr); in sil3114_spin_up()
292 status = sata_busy_wait (&port[num].ioaddr, ATA_BUSY, 30000, 0); in sil3114_spin_up()
296 port[num].dev_mask &= ~0x01; in sil3114_spin_up()
303 status = check_power_mode (num); in sil3114_spin_up()
320 static u8 check_power_mode (int num) in check_power_mode() argument
324 if (!(port[num].dev_mask & 0x01)) { in check_power_mode()
325 debug ("Device ata%d is not present\n", num); in check_power_mode()
329 if (!(sata_chk_status (&port[num].ioaddr, 0) & ATA_DRDY)) { in check_power_mode()
330 printf ("Device ata%d not ready\n", num); in check_power_mode()
334 writeb (0, port[num].ioaddr.feature_addr); in check_power_mode()
335 writeb (0, port[num].ioaddr.nsect_addr); in check_power_mode()
336 writeb (0, port[num].ioaddr.lbal_addr); in check_power_mode()
337 writeb (0, port[num].ioaddr.lbam_addr); in check_power_mode()
338 writeb (0, port[num].ioaddr.lbah_addr); in check_power_mode()
340 writeb (ATA_DEVICE_OBS, port[num].ioaddr.device_addr); in check_power_mode()
341 writeb (ATA_CMD_CHK_POWER, port[num].ioaddr.command_addr); in check_power_mode()
343 status = sata_busy_wait (&port[num].ioaddr, ATA_BUSY, 5000, 0); in check_power_mode()
348 port[num].dev_mask &= ~0x01; in check_power_mode()
351 res = readb (port[num].ioaddr.nsect_addr); in check_power_mode()
371 static u8 wait_for_irq (int num, unsigned int max) in wait_for_irq() argument
375 switch (num) { in wait_for_irq()
558 unsigned char status = 0, num = 0; in sata_write() local
573 num = device; in sata_write()
576 status = sata_busy_wait (&port[num].ioaddr, ATA_BUSY, 500, 0); in sata_write()
578 printf ("ata%u failed to respond\n", port[num].port_no); in sata_write()
584 writeb (0, port[num].ioaddr.nsect_addr); in sata_write()
586 port[num].ioaddr.lbal_addr); in sata_write()
588 port[num].ioaddr.lbam_addr); in sata_write()
590 port[num].ioaddr.lbah_addr); in sata_write()
593 writeb (1, port[num].ioaddr.nsect_addr); in sata_write()
594 writeb ((blknr >> 0) & 0xFF, port[num].ioaddr.lbal_addr); in sata_write()
595 writeb ((blknr >> 8) & 0xFF, port[num].ioaddr.lbam_addr); in sata_write()
596 writeb ((blknr >> 16) & 0xFF, port[num].ioaddr.lbah_addr); in sata_write()
599 writeb (ATA_LBA, port[num].ioaddr.device_addr); in sata_write()
600 writeb (ATA_CMD_PIO_WRITE_EXT, port[num].ioaddr.command_addr); in sata_write()
605 port[num].ioaddr.device_addr); in sata_write()
606 writeb (ATA_CMD_PIO_WRITE, port[num].ioaddr.command_addr); in sata_write()
611 status = sata_busy_wait (&port[num].ioaddr, ATA_BUSY, 4000, 0); in sata_write()
618 output_data (&port[num].ioaddr, buffer, ATA_SECTOR_WORDS); in sata_write()
619 readb (port[num].ioaddr.altstatus_addr); in sata_write()