aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/sata_sil24.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-02-01 01:06:36 -0500
committerJeff Garzik <jeff@garzik.org>2007-02-09 17:39:38 -0500
commit0d5ff566779f894ca9937231a181eb31e4adff0e (patch)
treed1c7495c932581c1d41aa7f0fdb303348da49106 /drivers/ata/sata_sil24.c
parent1a68ff13c8a9b517de3fd4187dc525412a6eba1b (diff)
libata: convert to iomap
Convert libata core layer and LLDs to use iomap. * managed iomap is used. Pointer to pcim_iomap_table() is cached at host->iomap and used through out LLDs. This basically replaces host->mmio_base. * if possible, pcim_iomap_regions() is used Most iomap operation conversions are taken from Jeff Garzik <jgarzik@pobox.com>'s iomap branch. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/sata_sil24.c')
-rw-r--r--drivers/ata/sata_sil24.c73
1 files changed, 32 insertions, 41 deletions
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
index c7a3c0275bee..9dcf11e2c7b3 100644
--- a/drivers/ata/sata_sil24.c
+++ b/drivers/ata/sata_sil24.c
@@ -60,6 +60,9 @@ struct sil24_port_multiplier {
60}; 60};
61 61
62enum { 62enum {
63 SIL24_HOST_BAR = 0,
64 SIL24_PORT_BAR = 2,
65
63 /* 66 /*
64 * Global controller registers (128 bytes @ BAR0) 67 * Global controller registers (128 bytes @ BAR0)
65 */ 68 */
@@ -320,12 +323,6 @@ struct sil24_port_priv {
320 struct ata_taskfile tf; /* Cached taskfile registers */ 323 struct ata_taskfile tf; /* Cached taskfile registers */
321}; 324};
322 325
323/* ap->host->private_data */
324struct sil24_host_priv {
325 void __iomem *host_base; /* global controller control (128 bytes @BAR0) */
326 void __iomem *port_base; /* port registers (4 * 8192 bytes @BAR2) */
327};
328
329static void sil24_dev_config(struct ata_port *ap, struct ata_device *dev); 326static void sil24_dev_config(struct ata_port *ap, struct ata_device *dev);
330static u8 sil24_check_status(struct ata_port *ap); 327static u8 sil24_check_status(struct ata_port *ap);
331static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg); 328static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg);
@@ -462,7 +459,7 @@ static int sil24_tag(int tag)
462 459
463static void sil24_dev_config(struct ata_port *ap, struct ata_device *dev) 460static void sil24_dev_config(struct ata_port *ap, struct ata_device *dev)
464{ 461{
465 void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; 462 void __iomem *port = ap->ioaddr.cmd_addr;
466 463
467 if (dev->cdb_len == 16) 464 if (dev->cdb_len == 16)
468 writel(PORT_CS_CDB16, port + PORT_CTRL_STAT); 465 writel(PORT_CS_CDB16, port + PORT_CTRL_STAT);
@@ -473,7 +470,7 @@ static void sil24_dev_config(struct ata_port *ap, struct ata_device *dev)
473static inline void sil24_update_tf(struct ata_port *ap) 470static inline void sil24_update_tf(struct ata_port *ap)
474{ 471{
475 struct sil24_port_priv *pp = ap->private_data; 472 struct sil24_port_priv *pp = ap->private_data;
476 void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; 473 void __iomem *port = ap->ioaddr.cmd_addr;
477 struct sil24_prb __iomem *prb = port; 474 struct sil24_prb __iomem *prb = port;
478 u8 fis[6 * 4]; 475 u8 fis[6 * 4];
479 476
@@ -496,7 +493,7 @@ static int sil24_scr_map[] = {
496 493
497static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg) 494static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg)
498{ 495{
499 void __iomem *scr_addr = (void __iomem *)ap->ioaddr.scr_addr; 496 void __iomem *scr_addr = ap->ioaddr.scr_addr;
500 if (sc_reg < ARRAY_SIZE(sil24_scr_map)) { 497 if (sc_reg < ARRAY_SIZE(sil24_scr_map)) {
501 void __iomem *addr; 498 void __iomem *addr;
502 addr = scr_addr + sil24_scr_map[sc_reg] * 4; 499 addr = scr_addr + sil24_scr_map[sc_reg] * 4;
@@ -507,7 +504,7 @@ static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg)
507 504
508static void sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val) 505static void sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val)
509{ 506{
510 void __iomem *scr_addr = (void __iomem *)ap->ioaddr.scr_addr; 507 void __iomem *scr_addr = ap->ioaddr.scr_addr;
511 if (sc_reg < ARRAY_SIZE(sil24_scr_map)) { 508 if (sc_reg < ARRAY_SIZE(sil24_scr_map)) {
512 void __iomem *addr; 509 void __iomem *addr;
513 addr = scr_addr + sil24_scr_map[sc_reg] * 4; 510 addr = scr_addr + sil24_scr_map[sc_reg] * 4;
@@ -523,7 +520,7 @@ static void sil24_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
523 520
524static int sil24_init_port(struct ata_port *ap) 521static int sil24_init_port(struct ata_port *ap)
525{ 522{
526 void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; 523 void __iomem *port = ap->ioaddr.cmd_addr;
527 u32 tmp; 524 u32 tmp;
528 525
529 writel(PORT_CS_INIT, port + PORT_CTRL_STAT); 526 writel(PORT_CS_INIT, port + PORT_CTRL_STAT);
@@ -539,7 +536,7 @@ static int sil24_init_port(struct ata_port *ap)
539 536
540static int sil24_softreset(struct ata_port *ap, unsigned int *class) 537static int sil24_softreset(struct ata_port *ap, unsigned int *class)
541{ 538{
542 void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; 539 void __iomem *port = ap->ioaddr.cmd_addr;
543 struct sil24_port_priv *pp = ap->private_data; 540 struct sil24_port_priv *pp = ap->private_data;
544 struct sil24_prb *prb = &pp->cmd_block[0].ata.prb; 541 struct sil24_prb *prb = &pp->cmd_block[0].ata.prb;
545 dma_addr_t paddr = pp->cmd_block_dma; 542 dma_addr_t paddr = pp->cmd_block_dma;
@@ -599,7 +596,7 @@ static int sil24_softreset(struct ata_port *ap, unsigned int *class)
599 596
600static int sil24_hardreset(struct ata_port *ap, unsigned int *class) 597static int sil24_hardreset(struct ata_port *ap, unsigned int *class)
601{ 598{
602 void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; 599 void __iomem *port = ap->ioaddr.cmd_addr;
603 const char *reason; 600 const char *reason;
604 int tout_msec, rc; 601 int tout_msec, rc;
605 u32 tmp; 602 u32 tmp;
@@ -716,7 +713,7 @@ static unsigned int sil24_qc_issue(struct ata_queued_cmd *qc)
716{ 713{
717 struct ata_port *ap = qc->ap; 714 struct ata_port *ap = qc->ap;
718 struct sil24_port_priv *pp = ap->private_data; 715 struct sil24_port_priv *pp = ap->private_data;
719 void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; 716 void __iomem *port = ap->ioaddr.cmd_addr;
720 unsigned int tag = sil24_tag(qc->tag); 717 unsigned int tag = sil24_tag(qc->tag);
721 dma_addr_t paddr; 718 dma_addr_t paddr;
722 void __iomem *activate; 719 void __iomem *activate;
@@ -737,7 +734,7 @@ static void sil24_irq_clear(struct ata_port *ap)
737 734
738static void sil24_freeze(struct ata_port *ap) 735static void sil24_freeze(struct ata_port *ap)
739{ 736{
740 void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; 737 void __iomem *port = ap->ioaddr.cmd_addr;
741 738
742 /* Port-wide IRQ mask in HOST_CTRL doesn't really work, clear 739 /* Port-wide IRQ mask in HOST_CTRL doesn't really work, clear
743 * PORT_IRQ_ENABLE instead. 740 * PORT_IRQ_ENABLE instead.
@@ -747,7 +744,7 @@ static void sil24_freeze(struct ata_port *ap)
747 744
748static void sil24_thaw(struct ata_port *ap) 745static void sil24_thaw(struct ata_port *ap)
749{ 746{
750 void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; 747 void __iomem *port = ap->ioaddr.cmd_addr;
751 u32 tmp; 748 u32 tmp;
752 749
753 /* clear IRQ */ 750 /* clear IRQ */
@@ -760,7 +757,7 @@ static void sil24_thaw(struct ata_port *ap)
760 757
761static void sil24_error_intr(struct ata_port *ap) 758static void sil24_error_intr(struct ata_port *ap)
762{ 759{
763 void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; 760 void __iomem *port = ap->ioaddr.cmd_addr;
764 struct ata_eh_info *ehi = &ap->eh_info; 761 struct ata_eh_info *ehi = &ap->eh_info;
765 int freeze = 0; 762 int freeze = 0;
766 u32 irq_stat; 763 u32 irq_stat;
@@ -838,7 +835,7 @@ static void sil24_finish_qc(struct ata_queued_cmd *qc)
838 835
839static inline void sil24_host_intr(struct ata_port *ap) 836static inline void sil24_host_intr(struct ata_port *ap)
840{ 837{
841 void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; 838 void __iomem *port = ap->ioaddr.cmd_addr;
842 u32 slot_stat, qc_active; 839 u32 slot_stat, qc_active;
843 int rc; 840 int rc;
844 841
@@ -873,12 +870,12 @@ static inline void sil24_host_intr(struct ata_port *ap)
873static irqreturn_t sil24_interrupt(int irq, void *dev_instance) 870static irqreturn_t sil24_interrupt(int irq, void *dev_instance)
874{ 871{
875 struct ata_host *host = dev_instance; 872 struct ata_host *host = dev_instance;
876 struct sil24_host_priv *hpriv = host->private_data; 873 void __iomem *host_base = host->iomap[SIL24_HOST_BAR];
877 unsigned handled = 0; 874 unsigned handled = 0;
878 u32 status; 875 u32 status;
879 int i; 876 int i;
880 877
881 status = readl(hpriv->host_base + HOST_IRQ_STAT); 878 status = readl(host_base + HOST_IRQ_STAT);
882 879
883 if (status == 0xffffffff) { 880 if (status == 0xffffffff) {
884 printk(KERN_ERR DRV_NAME ": IRQ status == 0xffffffff, " 881 printk(KERN_ERR DRV_NAME ": IRQ status == 0xffffffff, "
@@ -1031,7 +1028,6 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1031 unsigned int board_id = (unsigned int)ent->driver_data; 1028 unsigned int board_id = (unsigned int)ent->driver_data;
1032 struct ata_port_info *pinfo = &sil24_port_info[board_id]; 1029 struct ata_port_info *pinfo = &sil24_port_info[board_id];
1033 struct ata_probe_ent *probe_ent; 1030 struct ata_probe_ent *probe_ent;
1034 struct sil24_host_priv *hpriv;
1035 void __iomem *host_base; 1031 void __iomem *host_base;
1036 void __iomem *port_base; 1032 void __iomem *port_base;
1037 int i, rc; 1033 int i, rc;
@@ -1044,20 +1040,15 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1044 if (rc) 1040 if (rc)
1045 return rc; 1041 return rc;
1046 1042
1047 rc = pci_request_regions(pdev, DRV_NAME); 1043 rc = pcim_iomap_regions(pdev,
1044 (1 << SIL24_HOST_BAR) | (1 << SIL24_PORT_BAR),
1045 DRV_NAME);
1048 if (rc) 1046 if (rc)
1049 return rc; 1047 return rc;
1050 1048
1051 /* map mmio registers */ 1049 /* allocate & init probe_ent */
1052 host_base = pcim_iomap(pdev, 0, 0);
1053 port_base = pcim_iomap(pdev, 2, 0);
1054 if (!host_base || !port_base)
1055 return -ENOMEM;
1056
1057 /* allocate & init probe_ent and hpriv */
1058 probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL); 1050 probe_ent = devm_kzalloc(dev, sizeof(*probe_ent), GFP_KERNEL);
1059 hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL); 1051 if (!probe_ent)
1060 if (!probe_ent || !hpriv)
1061 return -ENOMEM; 1052 return -ENOMEM;
1062 1053
1063 probe_ent->dev = pci_dev_to_dev(pdev); 1054 probe_ent->dev = pci_dev_to_dev(pdev);
@@ -1073,10 +1064,10 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1073 1064
1074 probe_ent->irq = pdev->irq; 1065 probe_ent->irq = pdev->irq;
1075 probe_ent->irq_flags = IRQF_SHARED; 1066 probe_ent->irq_flags = IRQF_SHARED;
1076 probe_ent->private_data = hpriv; 1067 probe_ent->iomap = pcim_iomap_table(pdev);
1077 1068
1078 hpriv->host_base = host_base; 1069 host_base = probe_ent->iomap[SIL24_HOST_BAR];
1079 hpriv->port_base = port_base; 1070 port_base = probe_ent->iomap[SIL24_PORT_BAR];
1080 1071
1081 /* 1072 /*
1082 * Configure the device 1073 * Configure the device
@@ -1118,11 +1109,10 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1118 } 1109 }
1119 1110
1120 for (i = 0; i < probe_ent->n_ports; i++) { 1111 for (i = 0; i < probe_ent->n_ports; i++) {
1121 unsigned long portu = 1112 void __iomem *port = port_base + i * PORT_REGS_SIZE;
1122 (unsigned long)port_base + i * PORT_REGS_SIZE;
1123 1113
1124 probe_ent->port[i].cmd_addr = portu; 1114 probe_ent->port[i].cmd_addr = port;
1125 probe_ent->port[i].scr_addr = portu + PORT_SCONTROL; 1115 probe_ent->port[i].scr_addr = port + PORT_SCONTROL;
1126 1116
1127 ata_std_ports(&probe_ent->port[i]); 1117 ata_std_ports(&probe_ent->port[i]);
1128 } 1118 }
@@ -1143,7 +1133,8 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1143static int sil24_pci_device_resume(struct pci_dev *pdev) 1133static int sil24_pci_device_resume(struct pci_dev *pdev)
1144{ 1134{
1145 struct ata_host *host = dev_get_drvdata(&pdev->dev); 1135 struct ata_host *host = dev_get_drvdata(&pdev->dev);
1146 struct sil24_host_priv *hpriv = host->private_data; 1136 void __iomem *host_base = host->iomap[SIL24_HOST_BAR];
1137 void __iomem *port_base = host->iomap[SIL24_PORT_BAR];
1147 int rc; 1138 int rc;
1148 1139
1149 rc = ata_pci_device_do_resume(pdev); 1140 rc = ata_pci_device_do_resume(pdev);
@@ -1151,10 +1142,10 @@ static int sil24_pci_device_resume(struct pci_dev *pdev)
1151 return rc; 1142 return rc;
1152 1143
1153 if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) 1144 if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND)
1154 writel(HOST_CTRL_GLOBAL_RST, hpriv->host_base + HOST_CTRL); 1145 writel(HOST_CTRL_GLOBAL_RST, host_base + HOST_CTRL);
1155 1146
1156 sil24_init_controller(pdev, host->n_ports, host->ports[0]->flags, 1147 sil24_init_controller(pdev, host->n_ports, host->ports[0]->flags,
1157 hpriv->host_base, hpriv->port_base); 1148 host_base, port_base);
1158 1149
1159 ata_host_resume(host); 1150 ata_host_resume(host);
1160 1151