diff options
Diffstat (limited to 'drivers/ata/sata_promise.c')
-rw-r--r-- | drivers/ata/sata_promise.c | 118 |
1 files changed, 30 insertions, 88 deletions
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c index 11c1afea2db2..5a10dc5048ad 100644 --- a/drivers/ata/sata_promise.c +++ b/drivers/ata/sata_promise.c | |||
@@ -143,103 +143,57 @@ static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile | |||
143 | static int pdc_check_atapi_dma(struct ata_queued_cmd *qc); | 143 | static int pdc_check_atapi_dma(struct ata_queued_cmd *qc); |
144 | static int pdc_old_sata_check_atapi_dma(struct ata_queued_cmd *qc); | 144 | static int pdc_old_sata_check_atapi_dma(struct ata_queued_cmd *qc); |
145 | static void pdc_irq_clear(struct ata_port *ap); | 145 | static void pdc_irq_clear(struct ata_port *ap); |
146 | static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc); | 146 | static unsigned int pdc_qc_issue(struct ata_queued_cmd *qc); |
147 | static void pdc_freeze(struct ata_port *ap); | 147 | static void pdc_freeze(struct ata_port *ap); |
148 | static void pdc_sata_freeze(struct ata_port *ap); | 148 | static void pdc_sata_freeze(struct ata_port *ap); |
149 | static void pdc_thaw(struct ata_port *ap); | 149 | static void pdc_thaw(struct ata_port *ap); |
150 | static void pdc_sata_thaw(struct ata_port *ap); | 150 | static void pdc_sata_thaw(struct ata_port *ap); |
151 | static void pdc_pata_error_handler(struct ata_port *ap); | 151 | static void pdc_error_handler(struct ata_port *ap); |
152 | static void pdc_sata_error_handler(struct ata_port *ap); | ||
153 | static void pdc_post_internal_cmd(struct ata_queued_cmd *qc); | 152 | static void pdc_post_internal_cmd(struct ata_queued_cmd *qc); |
154 | static int pdc_pata_cable_detect(struct ata_port *ap); | 153 | static int pdc_pata_cable_detect(struct ata_port *ap); |
155 | static int pdc_sata_cable_detect(struct ata_port *ap); | 154 | static int pdc_sata_cable_detect(struct ata_port *ap); |
156 | 155 | ||
157 | static struct scsi_host_template pdc_ata_sht = { | 156 | static struct scsi_host_template pdc_ata_sht = { |
158 | .module = THIS_MODULE, | 157 | ATA_BASE_SHT(DRV_NAME), |
159 | .name = DRV_NAME, | ||
160 | .ioctl = ata_scsi_ioctl, | ||
161 | .queuecommand = ata_scsi_queuecmd, | ||
162 | .can_queue = ATA_DEF_QUEUE, | ||
163 | .this_id = ATA_SHT_THIS_ID, | ||
164 | .sg_tablesize = PDC_MAX_PRD, | 158 | .sg_tablesize = PDC_MAX_PRD, |
165 | .cmd_per_lun = ATA_SHT_CMD_PER_LUN, | ||
166 | .emulated = ATA_SHT_EMULATED, | ||
167 | .use_clustering = ATA_SHT_USE_CLUSTERING, | ||
168 | .proc_name = DRV_NAME, | ||
169 | .dma_boundary = ATA_DMA_BOUNDARY, | 159 | .dma_boundary = ATA_DMA_BOUNDARY, |
170 | .slave_configure = ata_scsi_slave_config, | ||
171 | .slave_destroy = ata_scsi_slave_destroy, | ||
172 | .bios_param = ata_std_bios_param, | ||
173 | }; | 160 | }; |
174 | 161 | ||
175 | static const struct ata_port_operations pdc_sata_ops = { | 162 | static const struct ata_port_operations pdc_common_ops = { |
176 | .tf_load = pdc_tf_load_mmio, | 163 | .inherits = &ata_sff_port_ops, |
177 | .tf_read = ata_tf_read, | ||
178 | .check_status = ata_check_status, | ||
179 | .exec_command = pdc_exec_command_mmio, | ||
180 | .dev_select = ata_std_dev_select, | ||
181 | .check_atapi_dma = pdc_check_atapi_dma, | ||
182 | 164 | ||
165 | .sff_tf_load = pdc_tf_load_mmio, | ||
166 | .sff_exec_command = pdc_exec_command_mmio, | ||
167 | .check_atapi_dma = pdc_check_atapi_dma, | ||
183 | .qc_prep = pdc_qc_prep, | 168 | .qc_prep = pdc_qc_prep, |
184 | .qc_issue = pdc_qc_issue_prot, | 169 | .qc_issue = pdc_qc_issue, |
185 | .freeze = pdc_sata_freeze, | 170 | .sff_irq_clear = pdc_irq_clear, |
186 | .thaw = pdc_sata_thaw, | ||
187 | .error_handler = pdc_sata_error_handler, | ||
188 | .post_internal_cmd = pdc_post_internal_cmd, | ||
189 | .cable_detect = pdc_sata_cable_detect, | ||
190 | .data_xfer = ata_data_xfer, | ||
191 | .irq_clear = pdc_irq_clear, | ||
192 | .irq_on = ata_irq_on, | ||
193 | 171 | ||
194 | .scr_read = pdc_sata_scr_read, | 172 | .post_internal_cmd = pdc_post_internal_cmd, |
195 | .scr_write = pdc_sata_scr_write, | 173 | .error_handler = pdc_error_handler, |
196 | .port_start = pdc_sata_port_start, | ||
197 | }; | 174 | }; |
198 | 175 | ||
199 | /* First-generation chips need a more restrictive ->check_atapi_dma op */ | 176 | static struct ata_port_operations pdc_sata_ops = { |
200 | static const struct ata_port_operations pdc_old_sata_ops = { | 177 | .inherits = &pdc_common_ops, |
201 | .tf_load = pdc_tf_load_mmio, | 178 | .cable_detect = pdc_sata_cable_detect, |
202 | .tf_read = ata_tf_read, | ||
203 | .check_status = ata_check_status, | ||
204 | .exec_command = pdc_exec_command_mmio, | ||
205 | .dev_select = ata_std_dev_select, | ||
206 | .check_atapi_dma = pdc_old_sata_check_atapi_dma, | ||
207 | |||
208 | .qc_prep = pdc_qc_prep, | ||
209 | .qc_issue = pdc_qc_issue_prot, | ||
210 | .freeze = pdc_sata_freeze, | 179 | .freeze = pdc_sata_freeze, |
211 | .thaw = pdc_sata_thaw, | 180 | .thaw = pdc_sata_thaw, |
212 | .error_handler = pdc_sata_error_handler, | ||
213 | .post_internal_cmd = pdc_post_internal_cmd, | ||
214 | .cable_detect = pdc_sata_cable_detect, | ||
215 | .data_xfer = ata_data_xfer, | ||
216 | .irq_clear = pdc_irq_clear, | ||
217 | .irq_on = ata_irq_on, | ||
218 | |||
219 | .scr_read = pdc_sata_scr_read, | 181 | .scr_read = pdc_sata_scr_read, |
220 | .scr_write = pdc_sata_scr_write, | 182 | .scr_write = pdc_sata_scr_write, |
221 | .port_start = pdc_sata_port_start, | 183 | .port_start = pdc_sata_port_start, |
222 | }; | 184 | }; |
223 | 185 | ||
224 | static const struct ata_port_operations pdc_pata_ops = { | 186 | /* First-generation chips need a more restrictive ->check_atapi_dma op */ |
225 | .tf_load = pdc_tf_load_mmio, | 187 | static struct ata_port_operations pdc_old_sata_ops = { |
226 | .tf_read = ata_tf_read, | 188 | .inherits = &pdc_sata_ops, |
227 | .check_status = ata_check_status, | 189 | .check_atapi_dma = pdc_old_sata_check_atapi_dma, |
228 | .exec_command = pdc_exec_command_mmio, | 190 | }; |
229 | .dev_select = ata_std_dev_select, | ||
230 | .check_atapi_dma = pdc_check_atapi_dma, | ||
231 | 191 | ||
232 | .qc_prep = pdc_qc_prep, | 192 | static struct ata_port_operations pdc_pata_ops = { |
233 | .qc_issue = pdc_qc_issue_prot, | 193 | .inherits = &pdc_common_ops, |
194 | .cable_detect = pdc_pata_cable_detect, | ||
234 | .freeze = pdc_freeze, | 195 | .freeze = pdc_freeze, |
235 | .thaw = pdc_thaw, | 196 | .thaw = pdc_thaw, |
236 | .error_handler = pdc_pata_error_handler, | ||
237 | .post_internal_cmd = pdc_post_internal_cmd, | ||
238 | .cable_detect = pdc_pata_cable_detect, | ||
239 | .data_xfer = ata_data_xfer, | ||
240 | .irq_clear = pdc_irq_clear, | ||
241 | .irq_on = ata_irq_on, | ||
242 | |||
243 | .port_start = pdc_common_port_start, | 197 | .port_start = pdc_common_port_start, |
244 | }; | 198 | }; |
245 | 199 | ||
@@ -451,7 +405,7 @@ static void pdc_atapi_pkt(struct ata_queued_cmd *qc) | |||
451 | u8 *cdb = qc->cdb; | 405 | u8 *cdb = qc->cdb; |
452 | struct pdc_port_priv *pp = ap->private_data; | 406 | struct pdc_port_priv *pp = ap->private_data; |
453 | u8 *buf = pp->pkt; | 407 | u8 *buf = pp->pkt; |
454 | u32 *buf32 = (u32 *) buf; | 408 | __le32 *buf32 = (__le32 *) buf; |
455 | unsigned int dev_sel, feature; | 409 | unsigned int dev_sel, feature; |
456 | 410 | ||
457 | /* set control bits (byte 0), zero delay seq id (byte 3), | 411 | /* set control bits (byte 0), zero delay seq id (byte 3), |
@@ -738,24 +692,12 @@ static void pdc_sata_thaw(struct ata_port *ap) | |||
738 | readl(host_mmio + hotplug_offset); /* flush */ | 692 | readl(host_mmio + hotplug_offset); /* flush */ |
739 | } | 693 | } |
740 | 694 | ||
741 | static void pdc_common_error_handler(struct ata_port *ap, ata_reset_fn_t hardreset) | 695 | static void pdc_error_handler(struct ata_port *ap) |
742 | { | 696 | { |
743 | if (!(ap->pflags & ATA_PFLAG_FROZEN)) | 697 | if (!(ap->pflags & ATA_PFLAG_FROZEN)) |
744 | pdc_reset_port(ap); | 698 | pdc_reset_port(ap); |
745 | 699 | ||
746 | /* perform recovery */ | 700 | ata_std_error_handler(ap); |
747 | ata_do_eh(ap, ata_std_prereset, ata_std_softreset, hardreset, | ||
748 | ata_std_postreset); | ||
749 | } | ||
750 | |||
751 | static void pdc_pata_error_handler(struct ata_port *ap) | ||
752 | { | ||
753 | pdc_common_error_handler(ap, NULL); | ||
754 | } | ||
755 | |||
756 | static void pdc_sata_error_handler(struct ata_port *ap) | ||
757 | { | ||
758 | pdc_common_error_handler(ap, sata_std_hardreset); | ||
759 | } | 701 | } |
760 | 702 | ||
761 | static void pdc_post_internal_cmd(struct ata_queued_cmd *qc) | 703 | static void pdc_post_internal_cmd(struct ata_queued_cmd *qc) |
@@ -952,7 +894,7 @@ static inline void pdc_packet_start(struct ata_queued_cmd *qc) | |||
952 | readl(ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); /* flush */ | 894 | readl(ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); /* flush */ |
953 | } | 895 | } |
954 | 896 | ||
955 | static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc) | 897 | static unsigned int pdc_qc_issue(struct ata_queued_cmd *qc) |
956 | { | 898 | { |
957 | switch (qc->tf.protocol) { | 899 | switch (qc->tf.protocol) { |
958 | case ATAPI_PROT_NODATA: | 900 | case ATAPI_PROT_NODATA: |
@@ -972,20 +914,20 @@ static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc) | |||
972 | break; | 914 | break; |
973 | } | 915 | } |
974 | 916 | ||
975 | return ata_qc_issue_prot(qc); | 917 | return ata_sff_qc_issue(qc); |
976 | } | 918 | } |
977 | 919 | ||
978 | static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf) | 920 | static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf) |
979 | { | 921 | { |
980 | WARN_ON(tf->protocol == ATA_PROT_DMA || tf->protocol == ATAPI_PROT_DMA); | 922 | WARN_ON(tf->protocol == ATA_PROT_DMA || tf->protocol == ATAPI_PROT_DMA); |
981 | ata_tf_load(ap, tf); | 923 | ata_sff_tf_load(ap, tf); |
982 | } | 924 | } |
983 | 925 | ||
984 | static void pdc_exec_command_mmio(struct ata_port *ap, | 926 | static void pdc_exec_command_mmio(struct ata_port *ap, |
985 | const struct ata_taskfile *tf) | 927 | const struct ata_taskfile *tf) |
986 | { | 928 | { |
987 | WARN_ON(tf->protocol == ATA_PROT_DMA || tf->protocol == ATAPI_PROT_DMA); | 929 | WARN_ON(tf->protocol == ATA_PROT_DMA || tf->protocol == ATAPI_PROT_DMA); |
988 | ata_exec_command(ap, tf); | 930 | ata_sff_exec_command(ap, tf); |
989 | } | 931 | } |
990 | 932 | ||
991 | static int pdc_check_atapi_dma(struct ata_queued_cmd *qc) | 933 | static int pdc_check_atapi_dma(struct ata_queued_cmd *qc) |